#2800 - CognitoIdentity - Fix format of Identity ID
This commit is contained in:
parent
7419f527d4
commit
280db9df6c
@ -1,5 +1,5 @@
|
|||||||
from moto.core.utils import get_random_hex
|
from uuid import uuid4
|
||||||
|
|
||||||
|
|
||||||
def get_random_identity_id(region):
|
def get_random_identity_id(region):
|
||||||
return "{0}:{1}".format(region, get_random_hex(length=19))
|
return "{0}:{1}".format(region, uuid4())
|
||||||
|
@ -7,6 +7,7 @@ from nose.tools import assert_raises
|
|||||||
from moto import mock_cognitoidentity
|
from moto import mock_cognitoidentity
|
||||||
from moto.cognitoidentity.utils import get_random_identity_id
|
from moto.cognitoidentity.utils import get_random_identity_id
|
||||||
from moto.core import ACCOUNT_ID
|
from moto.core import ACCOUNT_ID
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
|
||||||
@mock_cognitoidentity
|
@mock_cognitoidentity
|
||||||
@ -83,8 +84,10 @@ def test_describe_identity_pool_with_invalid_id_raises_error():
|
|||||||
|
|
||||||
# testing a helper function
|
# testing a helper function
|
||||||
def test_get_random_identity_id():
|
def test_get_random_identity_id():
|
||||||
assert len(get_random_identity_id("us-west-2")) > 0
|
identity_id = get_random_identity_id("us-west-2")
|
||||||
assert len(get_random_identity_id("us-west-2").split(":")[1]) == 19
|
region, id = identity_id.split(":")
|
||||||
|
region.should.equal("us-west-2")
|
||||||
|
UUID(id, version=4) # Will throw an error if it's not a valid UUID
|
||||||
|
|
||||||
|
|
||||||
@mock_cognitoidentity
|
@mock_cognitoidentity
|
||||||
@ -96,7 +99,6 @@ def test_get_id():
|
|||||||
IdentityPoolId="us-west-2:12345",
|
IdentityPoolId="us-west-2:12345",
|
||||||
Logins={"someurl": "12345"},
|
Logins={"someurl": "12345"},
|
||||||
)
|
)
|
||||||
print(result)
|
|
||||||
assert (
|
assert (
|
||||||
result.get("IdentityId", "").startswith("us-west-2")
|
result.get("IdentityId", "").startswith("us-west-2")
|
||||||
or result.get("ResponseMetadata").get("HTTPStatusCode") == 200
|
or result.get("ResponseMetadata").get("HTTPStatusCode") == 200
|
||||||
|
@ -48,6 +48,5 @@ def test_get_id():
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
print(res.data)
|
|
||||||
json_data = json.loads(res.data.decode("utf-8"))
|
json_data = json.loads(res.data.decode("utf-8"))
|
||||||
assert ":" in json_data["IdentityId"]
|
assert ":" in json_data["IdentityId"]
|
||||||
|
Loading…
Reference in New Issue
Block a user