Пример #1
0
    def test_valuemap(self):
        expected = [{
            'attrValue': 'client_113',
            'tenantAttrValue': '22cdbc5bb401d737b088c9'
        }, {
            'attrValue': 'client_843',
            'tenantAttrValue': '66cdbc5bb401d737b088c9'
        }]
        actual = Instances.mkValueMap(
            ('attrValue', 'tenantAttrValue'),
            (('client_113', '22cdbc5bb401d737b088c9'),
             ('client_843', '66cdbc5bb401d737b088c9')))
        assert actual == expected

        expected = [{
            'attrValue': 'Fido',
            'thirdPartyAttrValue': 'His Royal Fidoness'
        }, {
            'attrValue': 'brown',
            'thirdPartyAttrValue': 'Autumn Sunset'
        }]
        actual = Instances.mkValueMap(
            ('attrValue', 'thirdPartyAttrValue'),
            (('Fido', 'His Royal Fidoness'), ('brown', 'Autumn Sunset')))
        assert actual == expected
Пример #2
0
 def test_custom(self):
     self.base_display_name(Instances.mkCustom)
     self.base_logo(Instances.mkCustom)
     with self.assertRaises(AssertionError):
         Instances.mkCustom(display_name='bad auth type',
                            inbound_auth_type='BAD UNIT TEST VALUE')
     # Now a variant that should work.
     testname = 'Custom integration unit test'
     fakeuuid = 'deadbeef'
     auth_type = 'OAUTH2'
     actual = Instances.mkCustom(display_name=testname,
                                 parent_uuid=fakeuuid,
                                 inbound_auth_type=auth_type)
     expected = {
         'displayName': testname,
         'parentIntg': {
             'id': fakeuuid
         },
         'inboundConfig': {
             'authentication': {
                 'authType': auth_type
             }
         }
     }
     assert actual == expected
     # exercise the auth_type helper while we have a suitable struct.
     atypes = Instances.auth_type(actual)
     assert atypes == (auth_type, None)
Пример #3
0
 def test_redaction(self):
     original = {
         'inboundConfig': {
             'authentication': {
                 'token': 'shakespeare'
             }
         },
         'outboundConfig': {
             'authentication': {
                 'apiKeyPairs': [{
                     'char1': 'juliet',
                     'char2': 'goneril'
                 }]
             }
         }
     }
     # make a copy and check that it really is a copy.
     tvalues = copy.deepcopy(original)
     assert tvalues is not original
     assert tvalues == original
     # the redact function should modify the dict in place, not copy it.
     result = Instances.redact_response(tvalues)
     assert result is tvalues
     # check the redaction did what we expected.
     original['inboundConfig']['authentication']['token'] = 'REDACTED'
     original['outboundConfig']['authentication']['apiKeyPairs'][0][
         'char1'] = 'REDACTED'
     original['outboundConfig']['authentication']['apiKeyPairs'][0][
         'char2'] = 'REDACTED'
     assert result is not original
     assert result == original
Пример #4
0
    def test_basenotifier(self):
        expected = {
            'type': 'REST_API',
            'baseURI': 'www.example.com',
            'authType': 'OAUTH2',
            'grantType': 'CLIENT_CREDENTIALS',
            'accessTokenURI': 'www.example.com/creds',
            'apiKey': '6h67PAAFscVPMwhQZFcshpcqN5b6pyU9',
            'apiSecret': 'totalandcompletenonsense'
        }
        actual = Instances.mkBaseNotifier(
            expected['type'],
            expected['baseURI'],
            access_token_uri=expected['accessTokenURI'],
            api_key=expected['apiKey'],
            api_secret=expected['apiSecret'])
        assert actual == expected

        expected = {
            'type': 'SOAP_API',
            'baseURI': 'www.example.com',
            'authType': 'NONE'
        }
        actual = Instances.mkBaseNotifier(expected['type'],
                                          expected['baseURI'],
                                          auth_type=expected['authType'])
        assert actual == expected

        expected = {
            'type': 'REST_API',
            'baseURI': 'www.example.com/whatevs',
            'authType': 'BASIC',
            'grantType': 'PASSWORD',
            'userName': '******',
            'password': '******'
        }
        actual = Instances.mkBaseNotifier(expected['type'],
                                          expected['baseURI'],
                                          auth_type=expected['authType'],
                                          grant_type=expected['grantType'],
                                          user_name=expected['userName'],
                                          password=expected['password'])
        assert actual == expected
Пример #5
0
 def test_ASM(self):
     testname = 'Azure ASM integration unit test'
     subscription_id = 'ABCDEFGHIJKLMNOP'
     mgmt_cert = 'Azure management cert'
     keystore_pass = '******'
     actual = Instances.mkAzureASM(display_name=testname,
                                   arm_subscription_id=subscription_id,
                                   arm_mgmt_cert=mgmt_cert,
                                   arm_keystore_pass=keystore_pass)
     expected = {
         'displayName': testname,
         'credential': {
             'credentialType': 'AZURE',
             'AzureType': 'ASM',
             'SubscriptionId': subscription_id,
             'ManagementCertificate': mgmt_cert,
             'KeystorePassword': keystore_pass
         }
     }
     assert actual == expected
Пример #6
0
 def test_ARM(self):
     testname = 'Azure ARM integration unit test'
     subscription_id = '123456789'
     tenant_id = 'Some random Azure tenant'
     client_id = 'Azure client shtuff'
     secret_key = 'Open Sesame I Say!'
     actual = Instances.mkAzureARM(display_name=testname,
                                   arm_subscription_id=subscription_id,
                                   arm_tenant_id=tenant_id,
                                   arm_client_id=client_id,
                                   arm_secret_key=secret_key)
     expected = {
         'displayName': testname,
         'credential': {
             'credentialType': 'AZURE',
             'AzureType': 'ARM',
             'SubscriptionId': subscription_id,
             'TenantId': tenant_id,
             'ClientID': client_id,
             'SecretKey': secret_key
         }
     }
     assert actual == expected