Ejemplo n.º 1
0
    def test_format(self):
        fixture = AWSProfile('p', 'a', 'b', 'c')
        result_export = "export AWS_ACCESS_KEY_ID=a\nexport AWS_SECRET_ACCESS_KEY=b\nexport AWS_SESSION_TOKEN=c\nexport AWS_PROFILE=p"
        result_no_export = "AWS_ACCESS_KEY_ID=a\nAWS_SECRET_ACCESS_KEY=b\nAWS_SESSION_TOKEN=c\nAWS_PROFILE=p"

        self.assertEqual(result_export, fixture.format())
        self.assertEqual(result_no_export, fixture.format(export=False))
Ejemplo n.º 2
0
    def test_format(self):
        fixture = AWSProfile(None, 'a', 'b')
        result_export = "export AWS_ACCESS_KEY_ID=a\nexport AWS_SECRET_ACCESS_KEY=b"
        result_no_export = "AWS_ACCESS_KEY_ID=a\nAWS_SECRET_ACCESS_KEY=b"

        self.assertEqual(result_export, fixture.format())
        self.assertEqual(result_no_export, fixture.format(export=False))
Ejemplo n.º 3
0
    def test_constructor(self):
        fixture = AWSProfile('profile one', 'access key id', 'secret access key', 'session token')

        self.assertEqual('profile one', fixture.name)
        self.assertEqual('access key id', fixture.key_id)
        self.assertEqual('secret access key', fixture.secret_key)
        self.assertEqual('session token', fixture.session_token)
Ejemplo n.º 4
0
    def test_get(self):
        result = AWSCredentials(one=AWSProfile('one', 'key one', 'key two'))
        test = result.get('one')

        self.assertIsNotNone(test)
        self.assertTrue(isinstance(test, AWSProfile))
        self.assertEqual('key one', test.aws_access_key_id)
        self.assertEqual('key two', test.aws_secret_access_key)
Ejemplo n.º 5
0
    def test_add(self):
        result = AWSCredentials()

        self.assertEqual(0, len(result.profiles.keys()))

        valid = AWSProfile('profile', 'key id', 'key value')
        rc = result.add(valid)

        self.assertTrue(rc)
        self.assertEqual(valid, result.profiles.get('profile'))

        # test null secret key
        rc = result.add(AWSProfile('profile', 'key id', None))

        self.assertFalse(rc)
        self.assertEqual(1, len(result.profiles.keys()))

        # test empty secret key
        rc = result.add(AWSProfile('profile', 'key id', ''))

        self.assertFalse(rc)
        self.assertEqual(1, len(result.profiles.keys()))

        # test null access key
        rc = result.add(AWSProfile('profile', None, 'value'))

        self.assertFalse(rc)
        self.assertEqual(1, len(result.profiles.keys()))

        # test empty access key
        rc = result.add(AWSProfile('profile', '', 'value'))

        self.assertFalse(rc)
        self.assertEqual(1, len(result.profiles.keys()))

        # test null profile name
        rc = result.add(AWSProfile(None, 'key', 'value'))

        self.assertFalse(rc)
        self.assertEqual(1, len(result.profiles.keys()))

        # test empty profile name
        rc = result.add(AWSProfile('', 'key', 'value'))

        self.assertFalse(rc)
        self.assertEqual(1, len(result.profiles.keys()))
Ejemplo n.º 6
0
 def test_session_token(self):
     self.assertEqual('session token', AWSProfile(None, None, None, 'session token').aws_session_token)
Ejemplo n.º 7
0
 def test_secret_access_key(self):
     self.assertEqual('secret access key', AWSProfile(None, None, 'secret access key', None).aws_secret_access_key)
Ejemplo n.º 8
0
 def test_access_key_id(self):
     self.assertEqual('access key id', AWSProfile(None, 'access key id', None, None).aws_access_key_id)
Ejemplo n.º 9
0
 def test_ls(self):
     result = AWSCredentials(one=AWSProfile('one', 'a', 'b'), two=AWSProfile('two', 'a', 'b'), three=AWSProfile('three', 'a', 'b', 'c'))
     self.assertEqual(set(['one', 'two', 'three']), set(result.ls()))