Merge pull request #3 in PYTHON_PYVMOMI/pyvmomi from ~TEVESZ/pyvmomi:master to master
* commit '29d562462a8b73c0a6c4a34dab0d9c404a8b1b9c': Fixed indentation Copyright notice SSPI test Fixed indentation
This commit is contained in:
@@ -238,18 +238,19 @@ def Connect(host='localhost', port=443, user='root', pwd='',
|
||||
assert(version is None)
|
||||
version = versionMap[namespace]
|
||||
elif not version:
|
||||
version="vim.version.version6"
|
||||
version = "vim.version.version6"
|
||||
|
||||
si, stub = None, None
|
||||
if mechanism == 'userpass':
|
||||
si, stub = __Login(host, port, user, pwd, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
si, stub = __Login(host, port, user, pwd, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
elif mechanism == 'sspi':
|
||||
si, stub = __LoginBySSPI(host, port, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext, b64token)
|
||||
si, stub = __LoginBySSPI(host, port, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext, b64token)
|
||||
else:
|
||||
raise Exception( 'The provided connection mechanism is not available, the supported mechanisms are userpass or sspi' )
|
||||
|
||||
raise Exception('''The provided connection mechanism is not available, the
|
||||
supported mechanisms are userpass or sspi''')
|
||||
|
||||
SetSi(si)
|
||||
|
||||
return si
|
||||
@@ -317,7 +318,7 @@ def __Login(host, port, user, pwd, service, adapter, version, path,
|
||||
"""
|
||||
|
||||
content, si, stub = __RetrieveContent(host, port, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
|
||||
# Get a ticket if we're connecting to localhost and password is not specified
|
||||
if host == 'localhost' and not pwd:
|
||||
@@ -336,11 +337,12 @@ def __Login(host, port, user, pwd, service, adapter, version, path,
|
||||
raise
|
||||
return si, stub
|
||||
|
||||
## Private method that performs the actual Connect and returns a
|
||||
## Private method that performs LoginBySSPI and returns a
|
||||
## connected service instance object.
|
||||
## Copyright (c) 2015 Morgan Stanley. All rights reserved.
|
||||
|
||||
def __LoginBySSPI(host, port, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext, b64token):
|
||||
keyFile, certFile, thumbprint, sslContext, b64token):
|
||||
"""
|
||||
Private method that performs the actual Connect and returns a
|
||||
connected service instance object.
|
||||
@@ -360,7 +362,7 @@ def __LoginBySSPI(host, port, service, adapter, version, path,
|
||||
@param keyFile: ssl key file path
|
||||
@type keyFile: string
|
||||
@param certFile: ssl cert file path
|
||||
@type certFile: string
|
||||
@type certFile: string
|
||||
@param thumbprint: host cert thumbprint
|
||||
@type thumbprint: string
|
||||
@param sslContext: SSL Context describing the various SSL options. It is only
|
||||
@@ -371,10 +373,10 @@ def __LoginBySSPI(host, port, service, adapter, version, path,
|
||||
"""
|
||||
|
||||
content, si, stub = __RetrieveContent(host, port, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
|
||||
if b64token is None:
|
||||
raise Exception( 'Token is not defined for sspi login' )
|
||||
raise Exception('Token is not defined for sspi login')
|
||||
|
||||
# Login
|
||||
try:
|
||||
@@ -449,7 +451,7 @@ def __RetrieveContent(host, port, adapter, version, path, keyFile, certFile,
|
||||
reraise(vim.fault.HostConnectFault, fault, traceback)
|
||||
else:
|
||||
raise vim.fault.HostConnectFault(msg=str(e))
|
||||
|
||||
|
||||
return content, si, stub
|
||||
|
||||
|
||||
@@ -798,6 +800,6 @@ def OpenPathWithStub(path, stub):
|
||||
url = '%s://%s%s' % (protocol, hostPort, path)
|
||||
headers = {}
|
||||
if stub.cookie:
|
||||
headers["Cookie"] = stub.cookie
|
||||
headers["Cookie"] = stub.cookie
|
||||
return requests.get(url, headers=headers, verify=False)
|
||||
|
||||
|
258
tests/fixtures/sspi_connection.yaml
vendored
Normal file
258
tests/fixtures/sspi_connection.yaml
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><RetrieveServiceContent xmlns="urn:vim25"><_this type="ServiceInstance">ServiceInstance</_this></RetrieveServiceContent></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: ['']
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<RetrieveServiceContentResponse xmlns=\"urn:vim25\"><returnval><rootFolder\
|
||||
\ type=\"Folder\">group-d1</rootFolder><propertyCollector type=\"PropertyCollector\"\
|
||||
>propertyCollector</propertyCollector><viewManager type=\"ViewManager\">ViewManager</viewManager><about><name>VMware\
|
||||
\ vCenter Server</name><fullName>VMware vCenter Server 6.0.0 build-3018523</fullName><vendor>VMware,\
|
||||
\ Inc.</vendor><version>6.0.0</version><build>3018523</build><localeVersion>INTL</localeVersion><localeBuild>000</localeBuild><osType>linux-x64</osType><productLineId>vpx</productLineId><apiType>VirtualCenter</apiType><apiVersion>6.0</apiVersion><instanceUuid>6cbd40cc-1416-4b2d-ba7c-ae53a166d00a</instanceUuid><licenseProductName>VMware\
|
||||
\ VirtualCenter Server</licenseProductName><licenseProductVersion>6.0</licenseProductVersion></about><setting\
|
||||
\ type=\"OptionManager\">VpxSettings</setting><userDirectory type=\"UserDirectory\"\
|
||||
>UserDirectory</userDirectory><sessionManager type=\"SessionManager\">SessionManager</sessionManager><authorizationManager\
|
||||
\ type=\"AuthorizationManager\">AuthorizationManager</authorizationManager><perfManager\
|
||||
\ type=\"PerformanceManager\">PerfMgr</perfManager><scheduledTaskManager type=\"\
|
||||
ScheduledTaskManager\">ScheduledTaskManager</scheduledTaskManager><alarmManager\
|
||||
\ type=\"AlarmManager\">AlarmManager</alarmManager><eventManager type=\"EventManager\"\
|
||||
>EventManager</eventManager><taskManager type=\"TaskManager\">TaskManager</taskManager><extensionManager\
|
||||
\ type=\"ExtensionManager\">ExtensionManager</extensionManager><customizationSpecManager\
|
||||
\ type=\"CustomizationSpecManager\">CustomizationSpecManager</customizationSpecManager><customFieldsManager\
|
||||
\ type=\"CustomFieldsManager\">CustomFieldsManager</customFieldsManager><diagnosticManager\
|
||||
\ type=\"DiagnosticManager\">DiagMgr</diagnosticManager><licenseManager type=\"\
|
||||
LicenseManager\">LicenseManager</licenseManager><searchIndex type=\"SearchIndex\"\
|
||||
>SearchIndex</searchIndex><fileManager type=\"FileManager\">FileManager</fileManager><virtualDiskManager\
|
||||
\ type=\"VirtualDiskManager\">virtualDiskManager</virtualDiskManager><snmpSystem\
|
||||
\ type=\"HostSnmpSystem\">SnmpSystem</snmpSystem><vmProvisioningChecker type=\"\
|
||||
VirtualMachineProvisioningChecker\">ProvChecker</vmProvisioningChecker><vmCompatibilityChecker\
|
||||
\ type=\"VirtualMachineCompatibilityChecker\">CompatChecker</vmCompatibilityChecker><ovfManager\
|
||||
\ type=\"OvfManager\">OvfManager</ovfManager><ipPoolManager type=\"IpPoolManager\"\
|
||||
>IpPoolManager</ipPoolManager><dvSwitchManager type=\"DistributedVirtualSwitchManager\"\
|
||||
>DVSManager</dvSwitchManager><hostProfileManager type=\"HostProfileManager\"\
|
||||
>HostProfileManager</hostProfileManager><clusterProfileManager type=\"ClusterProfileManager\"\
|
||||
>ClusterProfileManager</clusterProfileManager><complianceManager type=\"ProfileComplianceManager\"\
|
||||
>MoComplianceManager</complianceManager><localizationManager type=\"LocalizationManager\"\
|
||||
>LocalizationManager</localizationManager><storageResourceManager type=\"\
|
||||
StorageResourceManager\">StorageResourceManager</storageResourceManager></returnval></RetrieveServiceContentResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['3320']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><LoginBySSPI xmlns="urn:vim25"><_this type="SessionManager">SessionManager</_this><base64Token>my_base64token</base64Token></LoginBySSPI></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: ['']
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<LoginResponse xmlns=\"urn:vim25\"><returnval><key>52b5395a-85c2-9902-7835-13a9b77e1fec</key><userName>my_user</userName><fullName>my_user</fullName><loginTime>2015-10-12T16:20:20.388804Z</loginTime><lastActiveTime>2015-10-12T16:20:20.388804Z</lastActiveTime><locale>en</locale><messageLocale>en</messageLocale></returnval></LoginResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['704']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
set-cookie: [vmware_soap_session="57e9ef0e1210352a3cf607db32a20792334f5b81";
|
||||
Path=/; HttpOnly; Secure;]
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><RetrieveServiceContent xmlns="urn:vim25"><_this type="ServiceInstance">ServiceInstance</_this></RetrieveServiceContent></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: [vmware_soap_session="57e9ef0e1210352a3cf607db32a20792334f5b81"; Path=/;
|
||||
HttpOnly; Secure;]
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<RetrieveServiceContentResponse xmlns=\"urn:vim25\"><returnval><rootFolder\
|
||||
\ type=\"Folder\">group-d1</rootFolder><propertyCollector type=\"PropertyCollector\"\
|
||||
>propertyCollector</propertyCollector><viewManager type=\"ViewManager\">ViewManager</viewManager><about><name>VMware\
|
||||
\ vCenter Server</name><fullName>VMware vCenter Server 6.0.0 build-3018523</fullName><vendor>VMware,\
|
||||
\ Inc.</vendor><version>6.0.0</version><build>3018523</build><localeVersion>INTL</localeVersion><localeBuild>000</localeBuild><osType>linux-x64</osType><productLineId>vpx</productLineId><apiType>VirtualCenter</apiType><apiVersion>6.0</apiVersion><instanceUuid>6cbd40cc-1416-4b2d-ba7c-ae53a166d00a</instanceUuid><licenseProductName>VMware\
|
||||
\ VirtualCenter Server</licenseProductName><licenseProductVersion>6.0</licenseProductVersion></about><setting\
|
||||
\ type=\"OptionManager\">VpxSettings</setting><userDirectory type=\"UserDirectory\"\
|
||||
>UserDirectory</userDirectory><sessionManager type=\"SessionManager\">SessionManager</sessionManager><authorizationManager\
|
||||
\ type=\"AuthorizationManager\">AuthorizationManager</authorizationManager><perfManager\
|
||||
\ type=\"PerformanceManager\">PerfMgr</perfManager><scheduledTaskManager type=\"\
|
||||
ScheduledTaskManager\">ScheduledTaskManager</scheduledTaskManager><alarmManager\
|
||||
\ type=\"AlarmManager\">AlarmManager</alarmManager><eventManager type=\"EventManager\"\
|
||||
>EventManager</eventManager><taskManager type=\"TaskManager\">TaskManager</taskManager><extensionManager\
|
||||
\ type=\"ExtensionManager\">ExtensionManager</extensionManager><customizationSpecManager\
|
||||
\ type=\"CustomizationSpecManager\">CustomizationSpecManager</customizationSpecManager><customFieldsManager\
|
||||
\ type=\"CustomFieldsManager\">CustomFieldsManager</customFieldsManager><diagnosticManager\
|
||||
\ type=\"DiagnosticManager\">DiagMgr</diagnosticManager><licenseManager type=\"\
|
||||
LicenseManager\">LicenseManager</licenseManager><searchIndex type=\"SearchIndex\"\
|
||||
>SearchIndex</searchIndex><fileManager type=\"FileManager\">FileManager</fileManager><virtualDiskManager\
|
||||
\ type=\"VirtualDiskManager\">virtualDiskManager</virtualDiskManager><snmpSystem\
|
||||
\ type=\"HostSnmpSystem\">SnmpSystem</snmpSystem><vmProvisioningChecker type=\"\
|
||||
VirtualMachineProvisioningChecker\">ProvChecker</vmProvisioningChecker><vmCompatibilityChecker\
|
||||
\ type=\"VirtualMachineCompatibilityChecker\">CompatChecker</vmCompatibilityChecker><ovfManager\
|
||||
\ type=\"OvfManager\">OvfManager</ovfManager><ipPoolManager type=\"IpPoolManager\"\
|
||||
>IpPoolManager</ipPoolManager><dvSwitchManager type=\"DistributedVirtualSwitchManager\"\
|
||||
>DVSManager</dvSwitchManager><hostProfileManager type=\"HostProfileManager\"\
|
||||
>HostProfileManager</hostProfileManager><clusterProfileManager type=\"ClusterProfileManager\"\
|
||||
>ClusterProfileManager</clusterProfileManager><complianceManager type=\"ProfileComplianceManager\"\
|
||||
>MoComplianceManager</complianceManager><localizationManager type=\"LocalizationManager\"\
|
||||
>LocalizationManager</localizationManager><storageResourceManager type=\"\
|
||||
StorageResourceManager\">StorageResourceManager</storageResourceManager></returnval></RetrieveServiceContentResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['3320']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><RetrievePropertiesEx xmlns="urn:vim25"><_this type="PropertyCollector">propertyCollector</_this><specSet><propSet><type>ServiceInstance</type><all>false</all><pathSet>content</pathSet></propSet><objectSet><obj
|
||||
type="ServiceInstance">ServiceInstance</obj><skip>false</skip></objectSet></specSet><options><maxObjects>1</maxObjects></options></RetrievePropertiesEx></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: [vmware_soap_session="57e9ef0e1210352a3cf607db32a20792334f5b81"; Path=/;
|
||||
HttpOnly; Secure;]
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<RetrievePropertiesExResponse xmlns=\"urn:vim25\"><returnval><objects><obj\
|
||||
\ type=\"ServiceInstance\">ServiceInstance</obj><propSet><name>content</name><val\
|
||||
\ xsi:type=\"ServiceContent\"><rootFolder type=\"Folder\">group-d1</rootFolder><propertyCollector\
|
||||
\ type=\"PropertyCollector\">propertyCollector</propertyCollector><viewManager\
|
||||
\ type=\"ViewManager\">ViewManager</viewManager><about><name>VMware vCenter\
|
||||
\ Server</name><fullName>VMware vCenter Server 6.0.0 build-3018523</fullName><vendor>VMware,\
|
||||
\ Inc.</vendor><version>6.0.0</version><build>3018523</build><localeVersion>INTL</localeVersion><localeBuild>000</localeBuild><osType>linux-x64</osType><productLineId>vpx</productLineId><apiType>VirtualCenter</apiType><apiVersion>6.0</apiVersion><instanceUuid>6cbd40cc-1416-4b2d-ba7c-ae53a166d00a</instanceUuid><licenseProductName>VMware\
|
||||
\ VirtualCenter Server</licenseProductName><licenseProductVersion>6.0</licenseProductVersion></about><setting\
|
||||
\ type=\"OptionManager\">VpxSettings</setting><userDirectory type=\"UserDirectory\"\
|
||||
>UserDirectory</userDirectory><sessionManager type=\"SessionManager\">SessionManager</sessionManager><authorizationManager\
|
||||
\ type=\"AuthorizationManager\">AuthorizationManager</authorizationManager><perfManager\
|
||||
\ type=\"PerformanceManager\">PerfMgr</perfManager><scheduledTaskManager type=\"\
|
||||
ScheduledTaskManager\">ScheduledTaskManager</scheduledTaskManager><alarmManager\
|
||||
\ type=\"AlarmManager\">AlarmManager</alarmManager><eventManager type=\"EventManager\"\
|
||||
>EventManager</eventManager><taskManager type=\"TaskManager\">TaskManager</taskManager><extensionManager\
|
||||
\ type=\"ExtensionManager\">ExtensionManager</extensionManager><customizationSpecManager\
|
||||
\ type=\"CustomizationSpecManager\">CustomizationSpecManager</customizationSpecManager><customFieldsManager\
|
||||
\ type=\"CustomFieldsManager\">CustomFieldsManager</customFieldsManager><diagnosticManager\
|
||||
\ type=\"DiagnosticManager\">DiagMgr</diagnosticManager><licenseManager type=\"\
|
||||
LicenseManager\">LicenseManager</licenseManager><searchIndex type=\"SearchIndex\"\
|
||||
>SearchIndex</searchIndex><fileManager type=\"FileManager\">FileManager</fileManager><virtualDiskManager\
|
||||
\ type=\"VirtualDiskManager\">virtualDiskManager</virtualDiskManager><snmpSystem\
|
||||
\ type=\"HostSnmpSystem\">SnmpSystem</snmpSystem><vmProvisioningChecker type=\"\
|
||||
VirtualMachineProvisioningChecker\">ProvChecker</vmProvisioningChecker><vmCompatibilityChecker\
|
||||
\ type=\"VirtualMachineCompatibilityChecker\">CompatChecker</vmCompatibilityChecker><ovfManager\
|
||||
\ type=\"OvfManager\">OvfManager</ovfManager><ipPoolManager type=\"IpPoolManager\"\
|
||||
>IpPoolManager</ipPoolManager><dvSwitchManager type=\"DistributedVirtualSwitchManager\"\
|
||||
>DVSManager</dvSwitchManager><hostProfileManager type=\"HostProfileManager\"\
|
||||
>HostProfileManager</hostProfileManager><clusterProfileManager type=\"ClusterProfileManager\"\
|
||||
>ClusterProfileManager</clusterProfileManager><complianceManager type=\"ProfileComplianceManager\"\
|
||||
>MoComplianceManager</complianceManager><localizationManager type=\"LocalizationManager\"\
|
||||
>LocalizationManager</localizationManager><storageResourceManager type=\"\
|
||||
StorageResourceManager\">StorageResourceManager</storageResourceManager></val></propSet></objects></returnval></RetrievePropertiesExResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['3460']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><RetrievePropertiesEx xmlns="urn:vim25"><_this type="PropertyCollector">propertyCollector</_this><specSet><propSet><type>SessionManager</type><all>false</all><pathSet>currentSession</pathSet></propSet><objectSet><obj
|
||||
type="SessionManager">SessionManager</obj><skip>false</skip></objectSet></specSet><options><maxObjects>1</maxObjects></options></RetrievePropertiesEx></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: [vmware_soap_session="57e9ef0e1210352a3cf607db32a20792334f5b81"; Path=/;
|
||||
HttpOnly; Secure;]
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<RetrievePropertiesExResponse xmlns=\"urn:vim25\"><returnval><objects><obj\
|
||||
\ type=\"SessionManager\">SessionManager</obj><propSet><name>currentSession</name><val\
|
||||
\ xsi:type=\"UserSession\"><key>52b5395a-85c2-9902-7835-13a9b77e1fec</key><userName>my_user</userName><fullName>my_user</fullName><loginTime>2015-10-12T16:20:20.388804Z</loginTime><lastActiveTime>2015-10-12T16:20:20.400795Z</lastActiveTime><locale>en</locale><messageLocale>en</messageLocale></val></propSet></objects></returnval></RetrievePropertiesExResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['880']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
@@ -40,6 +40,23 @@ class ConnectionTests(tests.VCRTestBase):
|
||||
self.assertTrue(session_id is not None)
|
||||
self.assertEqual('52b5395a-85c2-9902-7835-13a9b77e1fec', session_id)
|
||||
|
||||
@vcr.use_cassette('sspi_connection.yaml',
|
||||
cassette_library_dir=tests.fixtures_path,
|
||||
record_mode='none')
|
||||
def test_sspi_connection(self):
|
||||
# see: http://python3porting.com/noconv.html
|
||||
si = connect.Connect(host='vcsa',
|
||||
mechanism='sspi',
|
||||
b64token='my_base64token')
|
||||
cookie = si._stub.cookie
|
||||
session_id = si.content.sessionManager.currentSession.key
|
||||
# NOTE (hartsock): The cookie value should never change during
|
||||
# a connected session. That should be verifiable in these tests.
|
||||
self.assertEqual(cookie, si._stub.cookie)
|
||||
# NOTE (hartsock): assertIsNotNone does not work in Python 2.6
|
||||
self.assertTrue(session_id is not None)
|
||||
self.assertEqual('52b5395a-85c2-9902-7835-13a9b77e1fec', session_id)
|
||||
|
||||
@vcr.use_cassette('basic_connection_bad_password.yaml',
|
||||
cassette_library_dir=tests.fixtures_path,
|
||||
record_mode='none')
|
||||
|
Reference in New Issue
Block a user