sns#create_platform_endpoint: If token and attributes are the same, return endpoint (#4055)
* If token and attributes are the same, return endpoint * fix black * moto sns platform_endpoint.attributes includes only token,enabled * add tests when calling sns#create_platform_endpoint with same attrs for #4056
This commit is contained in:
parent
b44ab23c63
commit
c20a36b8cb
2 changed files with 35 additions and 5 deletions
|
|
@ -584,10 +584,13 @@ class SNSBackend(BaseBackend):
|
|||
def create_platform_endpoint(
|
||||
self, region, application, custom_user_data, token, attributes
|
||||
):
|
||||
if any(
|
||||
token == endpoint.token for endpoint in self.platform_endpoints.values()
|
||||
):
|
||||
raise DuplicateSnsEndpointError("Duplicate endpoint token: %s" % token)
|
||||
for endpoint in self.platform_endpoints.values():
|
||||
if token == endpoint.token:
|
||||
if attributes["Enabled"].lower() == endpoint.attributes["Enabled"]:
|
||||
return endpoint
|
||||
raise DuplicateSnsEndpointError(
|
||||
"Duplicate endpoint token with different attributes: %s" % token
|
||||
)
|
||||
platform_endpoint = PlatformEndpoint(
|
||||
region, application, custom_user_data, token, attributes
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue