def test_aws_session_class_session(): """AWSSession works""" boto3 = pytest.importorskip("boto3") sesh = AWSSession(session=boto3.session.Session(aws_access_key_id='foo', aws_secret_access_key='bar')) assert sesh._session assert sesh.get_credential_options()['AWS_ACCESS_KEY_ID'] == 'foo' assert sesh.get_credential_options()['AWS_SECRET_ACCESS_KEY'] == 'bar'
def test_aws_session_class_session(): """AWSSession works""" boto3 = pytest.importorskip("boto3") sesh = AWSSession(session=boto3.session.Session(aws_access_key_id='foo', aws_secret_access_key='bar')) assert sesh._session assert sesh.get_credential_options()['AWS_ACCESS_KEY_ID'] == 'foo' assert sesh.get_credential_options()['AWS_SECRET_ACCESS_KEY'] == 'bar'
def test_aws_session_class_profile(tmpdir, monkeypatch): """Confirm that profile_name kwarg works.""" pytest.importorskip("boto3") credentials_file = tmpdir.join('credentials') credentials_file.write("[testing]\n" "aws_access_key_id = foo\n" "aws_secret_access_key = bar\n" "aws_session_token = baz") monkeypatch.setenv('AWS_SHARED_CREDENTIALS_FILE', str(credentials_file)) monkeypatch.setenv('AWS_SESSION_TOKEN', 'ignore_me') sesh = AWSSession(profile_name='testing') assert sesh._session assert sesh.get_credential_options()['AWS_ACCESS_KEY_ID'] == 'foo' assert sesh.get_credential_options()['AWS_SECRET_ACCESS_KEY'] == 'bar' assert sesh.get_credential_options()['AWS_SESSION_TOKEN'] == 'baz' monkeypatch.undo()
def test_requester_pays(): """GDAL is configured with requester pays""" sesh = AWSSession(aws_access_key_id='foo', aws_secret_access_key='bar', requester_pays=True) assert sesh._session assert sesh.get_credential_options()['AWS_REQUEST_PAYER'] == 'requester'
def test_aws_session_class_profile(tmpdir, monkeypatch): """Confirm that profile_name kwarg works.""" pytest.importorskip("boto3") credentials_file = tmpdir.join('credentials') credentials_file.write("[testing]\n" "aws_access_key_id = foo\n" "aws_secret_access_key = bar\n" "aws_session_token = baz") monkeypatch.setenv('AWS_SHARED_CREDENTIALS_FILE', str(credentials_file)) monkeypatch.setenv('AWS_SESSION_TOKEN', 'ignore_me') sesh = AWSSession(profile_name='testing') assert sesh._session assert sesh.get_credential_options()['AWS_ACCESS_KEY_ID'] == 'foo' assert sesh.get_credential_options()['AWS_SECRET_ACCESS_KEY'] == 'bar' assert sesh.get_credential_options()['AWS_SESSION_TOKEN'] == 'baz' monkeypatch.undo()
def test_aws_session_class_unsigned(): """AWSSession works""" pytest.importorskip("boto3") sesh = AWSSession(aws_unsigned=True) assert sesh._session is None assert sesh.get_credential_options()['AWS_NO_SIGN_REQUEST'] == 'YES'
def test_aws_session_class(): """AWSSession works""" sesh = AWSSession(aws_access_key_id='foo', aws_secret_access_key='bar') assert sesh._session assert sesh.get_credential_options()['AWS_ACCESS_KEY_ID'] == 'foo' assert sesh.get_credential_options()['AWS_SECRET_ACCESS_KEY'] == 'bar'
def test_aws_session_class_endpoint(): """Confirm that endpoint_url kwarg works.""" pytest.importorskip("boto3") sesh = AWSSession(endpoint_url="example.com") assert sesh.get_credential_options()['AWS_S3_ENDPOINT'] == 'example.com'
def test_aws_session_class_unsigned(): """AWSSession works""" pytest.importorskip("boto3") sesh = AWSSession(aws_unsigned=True, region_name='us-mountain-1') assert sesh.get_credential_options()['AWS_NO_SIGN_REQUEST'] == 'YES' assert sesh.get_credential_options()['AWS_REGION'] == 'us-mountain-1'
def test_aws_session_class_unsigned(): """AWSSession works""" pytest.importorskip("boto3") sesh = AWSSession(aws_unsigned=True) assert sesh._session assert sesh.get_credential_options()['AWS_NO_SIGN_REQUEST'] == 'YES'
def test_aws_session_class(): """AWSSession works""" sesh = AWSSession(aws_access_key_id='foo', aws_secret_access_key='bar') assert sesh._session assert sesh.get_credential_options()['AWS_ACCESS_KEY_ID'] == 'foo' assert sesh.get_credential_options()['AWS_SECRET_ACCESS_KEY'] == 'bar'
def test_requester_pays(): """GDAL is configured with requester pays""" sesh = AWSSession(aws_access_key_id='foo', aws_secret_access_key='bar', requester_pays=True) assert sesh._session assert sesh.get_credential_options()['AWS_REQUEST_PAYER'] == 'requester'