46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
# type: ignore
|
||
|
from __future__ import annotations
|
||
|
|
||
|
import os
|
||
|
from unittest import mock
|
||
|
|
||
|
from keep_it_secret.ext import aws
|
||
|
|
||
|
|
||
|
@mock.patch.dict(
|
||
|
os.environ,
|
||
|
{
|
||
|
'AWS_ACCESS_KEY_ID': 'test_access_key_id',
|
||
|
'AWS_SECRET_ACCESS_KEY': 'test_secret_access_key',
|
||
|
'AWS_SESSION_TOKEN': 'test_aws_session_token',
|
||
|
'AWS_DEFAULT_REGION': 'test_aws_default_region',
|
||
|
},
|
||
|
)
|
||
|
def test_as_boto3_client_kwargs():
|
||
|
# Given
|
||
|
secrets = aws.AWSSecrets()
|
||
|
|
||
|
# When
|
||
|
result = secrets.as_boto3_client_kwargs()
|
||
|
|
||
|
# Then
|
||
|
assert result == {
|
||
|
'aws_access_key_id': 'test_access_key_id',
|
||
|
'aws_secret_access_key': 'test_secret_access_key',
|
||
|
'aws_session_token': 'test_aws_session_token',
|
||
|
'region_name': 'test_aws_default_region',
|
||
|
}
|
||
|
|
||
|
|
||
|
@mock.patch.dict(os.environ, {}, clear=True)
|
||
|
def test_as_boto3_client_kwargs_empty():
|
||
|
# Given
|
||
|
secrets = aws.AWSSecrets()
|
||
|
|
||
|
# When
|
||
|
result = secrets.as_boto3_client_kwargs()
|
||
|
|
||
|
# Then
|
||
|
assert result == {}
|