2021-10-18 19:44:29 +00:00
|
|
|
import sure # noqa # pylint: disable=unused-import
|
2013-05-24 21:22:34 +00:00
|
|
|
|
|
|
|
import moto.server as server
|
|
|
|
|
2019-10-31 15:44:26 +00:00
|
|
|
"""
|
2013-05-24 21:22:34 +00:00
|
|
|
Test the different server responses
|
2019-10-31 15:44:26 +00:00
|
|
|
"""
|
2013-05-24 21:22:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_sts_get_session_token():
|
2013-12-29 01:15:37 +00:00
|
|
|
backend = server.create_backend_app("sts")
|
|
|
|
test_client = backend.test_client()
|
|
|
|
|
2019-10-31 15:44:26 +00:00
|
|
|
res = test_client.get("/?Action=GetSessionToken")
|
2013-05-24 21:22:34 +00:00
|
|
|
res.status_code.should.equal(200)
|
2014-08-26 17:25:50 +00:00
|
|
|
res.data.should.contain(b"SessionToken")
|
|
|
|
res.data.should.contain(b"AccessKeyId")
|
2014-03-20 16:46:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_sts_get_federation_token():
|
|
|
|
backend = server.create_backend_app("sts")
|
|
|
|
test_client = backend.test_client()
|
|
|
|
|
2019-10-31 15:44:26 +00:00
|
|
|
res = test_client.get("/?Action=GetFederationToken&Name=Bob")
|
2014-03-20 16:46:03 +00:00
|
|
|
res.status_code.should.equal(200)
|
2014-08-26 17:25:50 +00:00
|
|
|
res.data.should.contain(b"SessionToken")
|
|
|
|
res.data.should.contain(b"AccessKeyId")
|
2017-01-19 03:59:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_sts_get_caller_identity():
|
|
|
|
backend = server.create_backend_app("sts")
|
|
|
|
test_client = backend.test_client()
|
|
|
|
|
2019-10-31 15:44:26 +00:00
|
|
|
res = test_client.get("/?Action=GetCallerIdentity")
|
2017-01-19 03:59:04 +00:00
|
|
|
res.status_code.should.equal(200)
|
|
|
|
res.data.should.contain(b"Arn")
|
|
|
|
res.data.should.contain(b"UserId")
|
|
|
|
res.data.should.contain(b"Account")
|
2021-11-25 10:03:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_sts_wellformed_xml():
|
|
|
|
backend = server.create_backend_app("sts")
|
|
|
|
test_client = backend.test_client()
|
|
|
|
|
|
|
|
res = test_client.get("/?Action=GetFederationToken&Name=Bob")
|
|
|
|
res.data.should_not.contain(b"\n")
|
|
|
|
res = test_client.get("/?Action=GetSessionToken")
|
|
|
|
res.data.should_not.contain(b"\n")
|
|
|
|
res = test_client.get("/?Action=GetCallerIdentity")
|
|
|
|
res.data.should_not.contain(b"\n")
|