예제 #1
0
    def test_get_partition_govcloud(self):
        creds = GimmeAWSCreds()

        partition = creds._get_partition_from_saml_acs('https://signin.amazonaws-us-gov.com/saml')
        self.assertEqual(partition, 'aws-us-gov')
예제 #2
0
    def test_get_partition_unkown(self):
        creds = GimmeAWSCreds()

        self.assertRaises(errors.GimmeAWSCredsExitBase, creds._get_partition_from_saml_acs,
                          'https://signin.amazonaws-foo.com/saml')
예제 #3
0
    def test_get_partition_aws(self):
        creds = GimmeAWSCreds()

        partition = creds._get_partition_from_saml_acs('https://signin.aws.amazon.com/saml')
        self.assertEqual(partition, 'aws')
예제 #4
0
    def test_get_partition_china(self):
        creds = GimmeAWSCreds()

        partition = creds._get_partition_from_saml_acs('https://signin.amazonaws.cn/saml')
        self.assertEqual(partition, 'aws-cn')
def gimme_aws_creds_as_metadata():
    aws_creds = GimmeAWSCreds()
    aws_creds.handle_action_configure()
    aws_creds.handle_action_register_device()
    aws_creds.handle_action_list_profiles()
    aws_creds.handle_action_store_json_creds()
    aws_creds.handle_action_list_roles()

    for data in aws_creds.iter_selected_aws_credentials():
        one_hour_from_now = datetime.datetime.now(
            tzutc()) + datetime.timedelta(hours=1)
        return dict(access_key=data['credentials']['aws_access_key_id'],
                    secret_key=data['credentials']['aws_secret_access_key'],
                    token=data['credentials']['aws_session_token'],
                    expiry_time=one_hour_from_now.isoformat())
예제 #6
0
    def test_missing_role_from_config(self, mock):
        creds = GimmeAWSCreds()

        selections = creds._get_selected_roles('test3', self.APP_INFO)
        self.assertEqual(selections, {'test1'})
예제 #7
0
    def test_get_selected_roles_from_config_1(self):
        creds = GimmeAWSCreds()

        selections = creds._get_selected_roles('test2', self.APP_INFO)
        self.assertEqual(selections, {'test2'})
예제 #8
0
    def test_get_selected_role_from_config_0(self):
        creds = GimmeAWSCreds()

        selection = creds._get_selected_role('test1', self.APP_INFO)
        self.assertEqual(selection, 'test1')
예제 #9
0
    def test_get_selected_app_from_config_1(self):
        creds = GimmeAWSCreds()

        selection = creds._get_selected_app('test2', self.AWS_INFO)
        self.assertEqual(selection, self.AWS_INFO[1])
예제 #10
0
    def test_missing_app_from_config(self, mock):
        creds = GimmeAWSCreds()

        selection = creds._get_selected_app('test3', self.AWS_INFO)
        self.assertEqual(selection, self.AWS_INFO[0])
예제 #11
0
 def test_choose_roles_app_a(self, mock):
     creds = GimmeAWSCreds()
     self.assertRaises(errors.GimmeAWSCredsExitBase, creds._choose_roles,
                       self.APP_INFO)
     self.assertRaises(errors.GimmeAWSCredsExitBase, creds._choose_app,
                       self.AWS_INFO)
예제 #12
0
#!/usr/bin/env python3
"""
Copyright 2016-present Nike, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and* limitations under the License.*
"""
from gimme_aws_creds.main import GimmeAWSCreds

if __name__ == '__main__':
    try:
        GimmeAWSCreds().run()
    except KeyboardInterrupt:
        pass
예제 #13
0
    def test_get_selected_role_all(self):
        creds = GimmeAWSCreds()

        selection = creds._get_selected_role('all', self.APP_INFO)
        self.assertEqual(selection, 'all')
예제 #14
0
 def test_get_alias_from_friendly_name_no_alias(self):
     creds = GimmeAWSCreds()
     friendly_name = "Account: 123456789012"
     self.assertEqual(creds._get_alias_from_friendly_name(friendly_name), None)
예제 #15
0
    def test_get_selected_roles_multiple(self):
        creds = GimmeAWSCreds()

        selections = creds._get_selected_roles('test1, test2', self.APP_INFO)
        self.assertEqual(selections, {'test1', 'test2'})
예제 #16
0
 def test_get_alias_from_friendly_name_with_alias(self):
     creds = GimmeAWSCreds()
     friendly_name = "Account: my-account-org (123456789012)"
     self.assertEqual(creds._get_alias_from_friendly_name(friendly_name), "my-account-org")
예제 #17
0
 def test_choose_role_app_a(self, mock):
     creds = GimmeAWSCreds()
     self.assertRaises(SystemExit, creds._choose_role, self.APP_INFO)
     self.assertRaises(SystemExit, creds._choose_app, self.AWS_INFO)