MCPcopy Create free account
hub / github.com/aws/aws-cli / setUp

Method setUp

tests/integration/botocore/test_credentials.py:147–174  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

145
146class TestAssumeRoleCredentials(BaseEnvVar):
147 def setUp(self):
148 self.env_original = os.environ.copy()
149 self.environ_copy = os.environ.copy()
150 super().setUp()
151 os.environ = self.environ_copy
152 # The tests rely on manipulating AWS_CONFIG_FILE,
153 # but we also need to make sure we don't accidentally
154 # pick up the ~/.aws/credentials file either.
155 os.environ['AWS_SHARED_CREDENTIALS_FILE'] = str(uuid4())
156 self.parent_session = Session()
157 self.iam = self.parent_session.create_client('iam')
158 self.sts = self.parent_session.create_client('sts')
159 self.tempdir = tempfile.mkdtemp()
160 self.config_file = os.path.join(self.tempdir, 'config')
161
162 # A role trust policy that allows the current account to call assume
163 # role on itself.
164 account_id = self.sts.get_caller_identity()['Account']
165 self.role_policy = {
166 "Version": "2012-10-17",
167 "Statement": [
168 {
169 "Effect": "Allow",
170 "Principal": {"AWS": f"arn:aws:iam::{account_id}:root"},
171 "Action": "sts:AssumeRole",
172 }
173 ],
174 }
175
176 def tearDown(self):
177 super().tearDown()

Callers

nothing calls this directly

Calls 4

SessionClass · 0.90
copyMethod · 0.45
setUpMethod · 0.45
create_clientMethod · 0.45

Tested by

no test coverage detected