-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix gundeck aws endpoint parsing (#2921)
Fix broken parser for "endpoint already exists" error message. It tried to consume the end twice. This could not work.
- Loading branch information
Showing
5 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The parser for the AWS/SNS error message to explain that an endpoint is already in use was incorrect. This lead to an "invalid token" error when registering push tokens for multiple user accounts (user ids) instead of updating the SNS endpoint with an additional user id. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -414,6 +414,7 @@ test-suite gundeck-tests | |
Json | ||
MockGundeck | ||
Native | ||
ParseExistsError | ||
Paths_gundeck | ||
Push | ||
ThreadBudget | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module ParseExistsError where | ||
|
||
import Amazonka.Types | ||
import Gundeck.Aws | ||
import Gundeck.Aws.Arn | ||
import Gundeck.Types.Push.V2 (Transport (APNS)) | ||
import Imports | ||
import Test.Tasty | ||
import Test.Tasty.HUnit | ||
|
||
tests :: TestTree | ||
tests = | ||
testGroup | ||
"parseExistsError" | ||
[ testCase "parse error string from real world example" parseErrorTest, | ||
testCase "parse errors" parseErrors | ||
] | ||
|
||
parseErrorTest :: Assertion | ||
parseErrorTest = | ||
let e = Just $ ErrorMessage "Invalid parameter: Token Reason: Endpoint arn:aws:sns:eu-west-1:093205192929:endpoint/APNS/staging-com.wire.dev.ent/f90c8f08-a0a1-33bc-aa43-23c94770d936 already exists with the same Token, but different attributes." | ||
expectedTopic = mkEndpointTopic (ArnEnv "staging") APNS "com.wire.dev.ent" (EndpointId "f90c8f08-a0a1-33bc-aa43-23c94770d936") | ||
expected = mkSnsArn Ireland (Account "093205192929") expectedTopic | ||
in parseExistsError e @?= Just expected | ||
|
||
parseErrors :: Assertion | ||
parseErrors = do | ||
parseExistsError Nothing @?= Nothing | ||
parseExistsError ((Just . ErrorMessage) "Invalid parameter: Token Reason: Endpoint") @?= Nothing | ||
parseExistsError | ||
( (Just . ErrorMessage) | ||
"Invalid parameter: Token Reason: Endpoint NO_ARN already exists with the same Token, but different attributes." | ||
) | ||
@?= Nothing | ||
parseExistsError | ||
( (Just . ErrorMessage) | ||
"Invalid parameter: Token Reason: Endpoint arn:aws:sns:eu-west-1:093205192929:endpoint/APNS/staging-com.wire.dev.ent/f90c8f08-a0a1-33bc-aa43-23c94770d936" | ||
) | ||
@?= Nothing |