diff --git a/tests/fixtures/sspi_connection.yaml b/tests/fixtures/sspi_connection.yaml new file mode 100644 index 0000000..ef268de --- /dev/null +++ b/tests/fixtures/sspi_connection.yaml @@ -0,0 +1,258 @@ +interactions: +- request: + body: ' + + + + <_this type="ServiceInstance">ServiceInstance + + ' + 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 "\n\ + \n\ngroup-d1propertyCollectorViewManagerVMware\ + \ vCenter ServerVMware vCenter Server 6.0.0 build-3018523VMware,\ + \ Inc.6.0.03018523INTL000linux-x64vpxVirtualCenter6.06cbd40cc-1416-4b2d-ba7c-ae53a166d00aVMware\ + \ VirtualCenter Server6.0VpxSettingsUserDirectorySessionManagerAuthorizationManagerPerfMgrScheduledTaskManagerAlarmManagerEventManagerTaskManagerExtensionManagerCustomizationSpecManagerCustomFieldsManagerDiagMgrLicenseManagerSearchIndexFileManagervirtualDiskManagerSnmpSystemProvCheckerCompatCheckerOvfManagerIpPoolManagerDVSManagerHostProfileManagerClusterProfileManagerMoComplianceManagerLocalizationManagerStorageResourceManager\n\ + \n"} + 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: ' + + + + <_this type="SessionManager">SessionManagermy_base64token + + ' + 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 "\n\ + \n\n52b5395a-85c2-9902-7835-13a9b77e1fecmy_usermy_user2015-10-12T16:20:20.388804Z2015-10-12T16:20:20.388804Zenen\n\ + \n"} + 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: ' + + + + <_this type="ServiceInstance">ServiceInstance + + ' + 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 "\n\ + \n\ngroup-d1propertyCollectorViewManagerVMware\ + \ vCenter ServerVMware vCenter Server 6.0.0 build-3018523VMware,\ + \ Inc.6.0.03018523INTL000linux-x64vpxVirtualCenter6.06cbd40cc-1416-4b2d-ba7c-ae53a166d00aVMware\ + \ VirtualCenter Server6.0VpxSettingsUserDirectorySessionManagerAuthorizationManagerPerfMgrScheduledTaskManagerAlarmManagerEventManagerTaskManagerExtensionManagerCustomizationSpecManagerCustomFieldsManagerDiagMgrLicenseManagerSearchIndexFileManagervirtualDiskManagerSnmpSystemProvCheckerCompatCheckerOvfManagerIpPoolManagerDVSManagerHostProfileManagerClusterProfileManagerMoComplianceManagerLocalizationManagerStorageResourceManager\n\ + \n"} + 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: ' + + + + <_this type="PropertyCollector">propertyCollectorServiceInstancefalsecontentServiceInstancefalse1 + + ' + 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 "\n\ + \n\nServiceInstancecontentgroup-d1propertyCollectorViewManagerVMware vCenter\ + \ ServerVMware vCenter Server 6.0.0 build-3018523VMware,\ + \ Inc.6.0.03018523INTL000linux-x64vpxVirtualCenter6.06cbd40cc-1416-4b2d-ba7c-ae53a166d00aVMware\ + \ VirtualCenter Server6.0VpxSettingsUserDirectorySessionManagerAuthorizationManagerPerfMgrScheduledTaskManagerAlarmManagerEventManagerTaskManagerExtensionManagerCustomizationSpecManagerCustomFieldsManagerDiagMgrLicenseManagerSearchIndexFileManagervirtualDiskManagerSnmpSystemProvCheckerCompatCheckerOvfManagerIpPoolManagerDVSManagerHostProfileManagerClusterProfileManagerMoComplianceManagerLocalizationManagerStorageResourceManager\n\ + \n"} + 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: ' + + + + <_this type="PropertyCollector">propertyCollectorSessionManagerfalsecurrentSessionSessionManagerfalse1 + + ' + 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 "\n\ + \n\nSessionManagercurrentSession52b5395a-85c2-9902-7835-13a9b77e1fecmy_usermy_user2015-10-12T16:20:20.388804Z2015-10-12T16:20:20.400795Zenen\n\ + \n"} + 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 diff --git a/tests/test_connect.py b/tests/test_connect.py index 308e831..c8c35c7 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -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')