Skip to content

Commit

Permalink
Ignore the voice_call field in POST /activation/send
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Jun 5, 2024
1 parent 5f82bcf commit c5992c5
Show file tree
Hide file tree
Showing 27 changed files with 74 additions and 100 deletions.
6 changes: 3 additions & 3 deletions libs/wire-api/src/Wire/API/User/Activation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ instance ToSchema ActivationResponse where
-- one can also request a call instead of SMS.
data SendActivationCode = SendActivationCode
{ saUserKey :: Email,
saLocale :: Maybe Locale,
saCall :: Bool
saLocale :: Maybe Locale
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform SendActivationCode)
Expand All @@ -209,10 +208,11 @@ instance ToSchema SendActivationCode where
SendActivationCode
<$> (maybeUserKeyToTuple . saUserKey) .= userKeyObjectSchema
<*> saLocale .= maybe_ (optFieldWithDocModifier "locale" (description ?~ "Locale to use for the activation code template.") schema)
<*> saCall .= (fromMaybe False <$> optFieldWithDocModifier "voice_call" (description ?~ "Request the code with a call instead (default is SMS).") schema)
<* const (Nothing :: Maybe Bool) .= maybe_ (optFieldWithDocModifier "voice_call" callDesc schema)
where
maybeUserKeyToTuple :: Email -> (Maybe Email, Maybe Phone)
maybeUserKeyToTuple email = (Just email, Nothing)
callDesc = description ?~ "This field is ignored as requesting a code via a call is not supported any more."

objectDesc :: NamedSwaggerDoc -> NamedSwaggerDoc
objectDesc =
Expand Down
37 changes: 24 additions & 13 deletions libs/wire-api/test/golden/Test/Wire/API/Golden/FromJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Test.Wire.API.Golden.Generated.Invite_user (testObject_Invite_user_2)
import Test.Wire.API.Golden.Generated.MemberUpdateData_user
import Test.Wire.API.Golden.Generated.NewOtrMessage_user
import Test.Wire.API.Golden.Generated.RmClient_user
import Test.Wire.API.Golden.Generated.SendActivationCode_user
import Test.Wire.API.Golden.Generated.SimpleMember_user
import Test.Wire.API.Golden.Runner
import Wire.API.Conversation (Conversation, MemberUpdate, OtherMemberUpdate)
Expand Down Expand Up @@ -102,18 +103,28 @@ tests =
(Just "only managed-by-Wire users can be created here.")
"testObject_NewUserPublic_user_1-3.json"
],
testGroup "SendActivationCode: failure" $
[ testCase "testObject_SendActivationCode_user_1.json" $
testFromJSONFailureWithMsg @SendActivationCode
(Just "The phone option is not supported any more.")
"testObject_SendActivationCode_user_1.json",
testCase "testObject_SendActivationCode_user_2.json" $
testFromJSONFailureWithMsg @SendActivationCode
(Just "Only 'email' allowed. The phone option is not supported any more.")
"testObject_SendActivationCode_user_2.json",
testCase "testObject_SendActivationCode_user_3.json" $
testFromJSONFailureWithMsg @SendActivationCode
(Just "The 'email' field is required.")
"testObject_SendActivationCode_user_3.json"
testGroup
"SendActivationCode"
[ testGroup "failure" $
[ testCase "testObject_SendActivationCode_user_1.json" $
testFromJSONFailureWithMsg @SendActivationCode
(Just "The phone option is not supported any more.")
"testObject_SendActivationCode_user_1.json",
testCase "testObject_SendActivationCode_user_2.json" $
testFromJSONFailureWithMsg @SendActivationCode
(Just "Only 'email' allowed. The phone option is not supported any more.")
"testObject_SendActivationCode_user_2.json",
testCase "testObject_SendActivationCode_user_3.json" $
testFromJSONFailureWithMsg @SendActivationCode
(Just "The 'email' field is required.")
"testObject_SendActivationCode_user_3.json"
],
testGroup
"success"
[ testCase
"with voice_call ignored"
$ testFromJSONObjects
[(testObject_SendActivationCode_user_20, "testObject_SendActivationCode_user_20_2.json")]
]
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@ testObject_SendActivationCode_user_1 =
SendActivationCode
{ saUserKey = Email {emailLocal = "test", emailDomain = "example.com"},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.CU, lCountry = Just (Country {fromCountry = VI})}),
saCall = False
Just (Locale {lLanguage = Language Data.LanguageCodes.CU, lCountry = Just (Country {fromCountry = VI})})
}

testObject_SendActivationCode_user_2 :: SendActivationCode
testObject_SendActivationCode_user_2 =
SendActivationCode
{ saUserKey = Email {emailLocal = "\1021635", emailDomain = "nK"},
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.DE, lCountry = Nothing}),
saCall = False
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.DE, lCountry = Nothing})
}

testObject_SendActivationCode_user_3 :: SendActivationCode
Expand All @@ -54,149 +52,131 @@ testObject_SendActivationCode_user_3 =
emailDomain = "-\DC32\1101045\&1\DC2\1014718\167922\SO\68149"
},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.GN, lCountry = Just (Country {fromCountry = VU})}),
saCall = True
Just (Locale {lLanguage = Language Data.LanguageCodes.GN, lCountry = Just (Country {fromCountry = VU})})
}

testObject_SendActivationCode_user_4 :: SendActivationCode
testObject_SendActivationCode_user_4 =
SendActivationCode
{ saUserKey = Email {emailLocal = "b", emailDomain = "4M\1076452P\149723$[\DC2j"},
saLocale = Nothing,
saCall = False
saLocale = Nothing
}

testObject_SendActivationCode_user_5 :: SendActivationCode
testObject_SendActivationCode_user_5 =
SendActivationCode
{ saUserKey = Email {emailLocal = "test", emailDomain = "example.com"},
saLocale = Nothing,
saCall = False
saLocale = Nothing
}

testObject_SendActivationCode_user_6 :: SendActivationCode
testObject_SendActivationCode_user_6 =
SendActivationCode
{ saUserKey = Email {emailLocal = "test", emailDomain = "example.com"},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.DV, lCountry = Just (Country {fromCountry = IN})}),
saCall = False
Just (Locale {lLanguage = Language Data.LanguageCodes.DV, lCountry = Just (Country {fromCountry = IN})})
}

testObject_SendActivationCode_user_7 :: SendActivationCode
testObject_SendActivationCode_user_7 =
SendActivationCode
{ saUserKey = Email {emailLocal = "B+l\1054055\1082148", emailDomain = "\a%"},
saLocale = Nothing,
saCall = True
saLocale = Nothing
}

testObject_SendActivationCode_user_8 :: SendActivationCode
testObject_SendActivationCode_user_8 =
SendActivationCode
{ saUserKey = Email {emailLocal = "\NUL3", emailDomain = "\59252g\155998\11926Ea?\DC2\\\DC4"},
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.HO, lCountry = Nothing}),
saCall = True
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.HO, lCountry = Nothing})
}

testObject_SendActivationCode_user_9 :: SendActivationCode
testObject_SendActivationCode_user_9 =
SendActivationCode
{ saUserKey = Email {emailLocal = "Rn\STXv", emailDomain = "(\NULN"},
saLocale = Nothing,
saCall = False
saLocale = Nothing
}

testObject_SendActivationCode_user_10 :: SendActivationCode
testObject_SendActivationCode_user_10 =
SendActivationCode
{ saUserKey = Email {emailLocal = "\t\1040376\NUL2\160662t\152821", emailDomain = "^s"},
saLocale = Nothing,
saCall = True
saLocale = Nothing
}

testObject_SendActivationCode_user_11 :: SendActivationCode
testObject_SendActivationCode_user_11 =
SendActivationCode
{ saUserKey = Email {emailLocal = "rT", emailDomain = "a\tL\DC4"},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.HY, lCountry = Just (Country {fromCountry = BB})}),
saCall = False
Just (Locale {lLanguage = Language Data.LanguageCodes.HY, lCountry = Just (Country {fromCountry = BB})})
}

testObject_SendActivationCode_user_12 :: SendActivationCode
testObject_SendActivationCode_user_12 =
SendActivationCode
{ saUserKey = Email {emailLocal = "test", emailDomain = "example.com"},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.VE, lCountry = Just (Country {fromCountry = MU})}),
saCall = True
Just (Locale {lLanguage = Language Data.LanguageCodes.VE, lCountry = Just (Country {fromCountry = MU})})
}

testObject_SendActivationCode_user_13 :: SendActivationCode
testObject_SendActivationCode_user_13 =
SendActivationCode
{ saUserKey = Email {emailLocal = "test", emailDomain = "example.com"},
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.KK, lCountry = Nothing}),
saCall = False
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.KK, lCountry = Nothing})
}

testObject_SendActivationCode_user_14 :: SendActivationCode
testObject_SendActivationCode_user_14 =
SendActivationCode
{ saUserKey = Email {emailLocal = "B;b\164357\DC1\SIHm\DC3{", emailDomain = "?\64159Jd\f"},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.KW, lCountry = Just (Country {fromCountry = PM})}),
saCall = False
Just (Locale {lLanguage = Language Data.LanguageCodes.KW, lCountry = Just (Country {fromCountry = PM})})
}

testObject_SendActivationCode_user_15 :: SendActivationCode
testObject_SendActivationCode_user_15 =
SendActivationCode
{ saUserKey = Email {emailLocal = "\1024828\DC1", emailDomain = "t=\69734\42178\1032441,AG2"},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.IU, lCountry = Just (Country {fromCountry = FR})}),
saCall = False
Just (Locale {lLanguage = Language Data.LanguageCodes.IU, lCountry = Just (Country {fromCountry = FR})})
}

testObject_SendActivationCode_user_16 :: SendActivationCode
testObject_SendActivationCode_user_16 =
SendActivationCode
{ saUserKey = Email {emailLocal = "O_\37211\1022996^t", emailDomain = ""},
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.FI, lCountry = Nothing}),
saCall = True
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.FI, lCountry = Nothing})
}

testObject_SendActivationCode_user_17 :: SendActivationCode
testObject_SendActivationCode_user_17 =
SendActivationCode
{ saUserKey = Email {emailLocal = "T\vI9H}C\STX\SO\1017900", emailDomain = "\151457\35555=N"},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.PA, lCountry = Just (Country {fromCountry = AO})}),
saCall = True
Just (Locale {lLanguage = Language Data.LanguageCodes.PA, lCountry = Just (Country {fromCountry = AO})})
}

testObject_SendActivationCode_user_18 :: SendActivationCode
testObject_SendActivationCode_user_18 =
SendActivationCode
{ saUserKey = Email {emailLocal = "test", emailDomain = "example.com"},
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.TG, lCountry = Nothing}),
saCall = True
saLocale = Just (Locale {lLanguage = Language Data.LanguageCodes.TG, lCountry = Nothing})
}

testObject_SendActivationCode_user_19 :: SendActivationCode
testObject_SendActivationCode_user_19 =
SendActivationCode
{ saUserKey = Email {emailLocal = "test", emailDomain = "example.com"},
saLocale =
Just (Locale {lLanguage = Language Data.LanguageCodes.GD, lCountry = Just (Country {fromCountry = FI})}),
saCall = True
Just (Locale {lLanguage = Language Data.LanguageCodes.GD, lCountry = Just (Country {fromCountry = FI})})
}

testObject_SendActivationCode_user_20 :: SendActivationCode
testObject_SendActivationCode_user_20 =
SendActivationCode
{ saUserKey = Email {emailLocal = "test", emailDomain = "example.com"},
saLocale = Nothing,
saCall = True
saLocale = Nothing
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"email": "[email protected]",
"voice_call": true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "[email protected]",
"locale": "cu-VI",
"voice_call": false
"locale": "cu-VI"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"email": "\t󽿸\u00002𧎖t𥓵@^s",
"voice_call": true
"email": "\t󽿸\u00002𧎖t𥓵@^s"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "rT@a\tL\u0014",
"locale": "hy-BB",
"voice_call": false
"locale": "hy-BB"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "[email protected]",
"locale": "ve-MU",
"voice_call": true
"locale": "ve-MU"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "[email protected]",
"locale": "kk",
"voice_call": false
"locale": "kk"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "B;b𨈅\u0011\u000fHm\u0013{@?犯Jd\u000c",
"locale": "kw-PM",
"voice_call": false
"locale": "kw-PM"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "󺌼\u0011@t=𑁦꓂󼃹,AG2",
"locale": "iu-FR",
"voice_call": false
"locale": "iu-FR"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "O_酛󹰔^t@",
"locale": "fi",
"voice_call": true
"locale": "fi"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "T\u000bI9H}C\u0002\u000e󸠬@𤾡諣=N",
"locale": "pa-AO",
"voice_call": true
"locale": "pa-AO"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "[email protected]",
"locale": "tg",
"voice_call": true
"locale": "tg"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "[email protected]",
"locale": "gd-FI",
"voice_call": true
"locale": "gd-FI"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "󹛃@nK",
"locale": "de",
"voice_call": false
"locale": "de"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"email": "[email protected]",
"voice_call": true
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "#\u0006􍖄l􅋋F𤀞@-\u00132􌳵1\u0012󷮾𨿲\u000e𐨵",
"locale": "gn-VU",
"voice_call": true
"locale": "gn-VU"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"email": "b@4M􆳤P𤣛$[\u0012j",
"voice_call": false
"email": "b@4M􆳤P𤣛$[\u0012j"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"email": "[email protected]",
"voice_call": false
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "[email protected]",
"locale": "dv-IN",
"voice_call": false
"locale": "dv-IN"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"email": "B+l􁕧􈌤@\u0007%",
"voice_call": true
"email": "B+l􁕧􈌤@\u0007%"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"email": "\u00003@g𦅞⺖Ea?\u0012\\\u0014",
"locale": "ho",
"voice_call": true
"locale": "ho"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"email": "Rn\u0002v@(\u0000N",
"voice_call": false
"email": "Rn\u0002v@(\u0000N"
}
Loading

0 comments on commit c5992c5

Please sign in to comment.