Skip to content

Commit

Permalink
Fix golden tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed Nov 14, 2022
1 parent 16da7ab commit bd078bb
Show file tree
Hide file tree
Showing 99 changed files with 266 additions and 271 deletions.
20 changes: 14 additions & 6 deletions libs/wire-api/src/Wire/API/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ instance ToSchema ConversationsResponse where
"ConversationsResponse"
(description ?~ "Response object for getting metadata of a list of conversations")
$ ConversationsResponse
<$> crFound .= field "found" (array schema)
<$> crFound .= field "found" (array (conversationSchema accessRolesSchemaV2))
<*> crNotFound .= fieldWithDocModifier "not_found" notFoundDoc (array schema)
<*> crFailed .= fieldWithDocModifier "failed" failedDoc (array schema)

Expand Down Expand Up @@ -875,12 +875,20 @@ data ConversationAccessData = ConversationAccessData
deriving (Arbitrary) via (GenericUniform ConversationAccessData)
deriving (FromJSON, ToJSON, S.ToSchema) via Schema ConversationAccessData

conversationAccessDataSchema ::
ObjectSchema SwaggerDoc (Set AccessRole) ->
ValueSchema NamedSwaggerDoc ConversationAccessData
conversationAccessDataSchema sch =
object "ConversationAccessData" $
ConversationAccessData
<$> cupAccess .= field "access" (set schema)
<*> cupAccessRoles .= sch

instance ToSchema ConversationAccessData where
schema =
object "ConversationAccessData" $
ConversationAccessData
<$> cupAccess .= field "access" (set schema)
<*> cupAccessRoles .= accessRolesSchema
schema = conversationAccessDataSchema accessRolesSchema

instance ToSchema (Versioned 'V2 ConversationAccessData) where
schema = Versioned <$> unVersioned .= conversationAccessDataSchema accessRolesSchemaV2

modelConversationAccessData :: Doc.Model
modelConversationAccessData = Doc.defineModel "ConversationAccessData" $ do
Expand Down
23 changes: 23 additions & 0 deletions libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,32 @@ type ConversationAPI =
(UpdateResponses "Access unchanged" "Access updated" Event)
(UpdateResult Event)
)
:<|> Named
"update-conversation-access@v2"
( Summary "Update access modes for a conversation"
:> Until 'V3
:> ZLocalUser
:> ZConn
:> CanThrow ('ActionDenied 'ModifyConversationAccess)
:> CanThrow ('ActionDenied 'RemoveConversationMember)
:> CanThrow 'ConvAccessDenied
:> CanThrow 'ConvNotFound
:> CanThrow 'InvalidOperation
:> CanThrow 'InvalidTargetAccess
:> "conversations"
:> QualifiedCapture' '[Description "Conversation ID"] "cnv" ConvId
:> "access"
:> VersionedReqBody 'V2 '[JSON] ConversationAccessData
:> MultiVerb
'PUT
'[JSON]
(UpdateResponses "Access unchanged" "Access updated" Event)
(UpdateResult Event)
)
:<|> Named
"update-conversation-access"
( Summary "Update access modes for a conversation"
:> From 'V3
:> ZLocalUser
:> ZConn
:> CanThrow ('ActionDenied 'ModifyConversationAccess)
Expand Down
31 changes: 26 additions & 5 deletions libs/wire-api/test/golden/Test/Wire/API/Golden/Generated.hs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ import qualified Test.Wire.API.Golden.Generated.WithStatusPatch_team
import qualified Test.Wire.API.Golden.Generated.WithStatus_team
import qualified Test.Wire.API.Golden.Generated.Wrapped_20_22some_5fint_22_20Int_user
import Test.Wire.API.Golden.Runner
import Wire.API.Routes.Version
import Wire.API.Routes.Versioned

tests :: TestTree
tests =
Expand Down Expand Up @@ -382,11 +384,21 @@ tests =
testObjects
[ (Test.Wire.API.Golden.Generated.ConnectionUpdate_user.testObject_ConnectionUpdate_user_1, "testObject_ConnectionUpdate_user_1.json")
],
testGroup "Golden: Conversation_user V2" $
testObjects
[ (Versioned @'V2 Test.Wire.API.Golden.Generated.Conversation_user.testObject_Conversation_user_1, "testObject_Conversation_v2_user_1.json"),
(Versioned @'V2 Test.Wire.API.Golden.Generated.Conversation_user.testObject_Conversation_user_2, "testObject_Conversation_v2_user_2.json")
],
testGroup "Golden: Conversation_user" $
testObjects
[ (Test.Wire.API.Golden.Generated.Conversation_user.testObject_Conversation_user_1, "testObject_Conversation_user_1.json"),
(Test.Wire.API.Golden.Generated.Conversation_user.testObject_Conversation_user_2, "testObject_Conversation_user_2.json")
],
testGroup "Golden: NewConv_user V2" $
testObjects
[ (Versioned @'V2 Test.Wire.API.Golden.Generated.NewConv_user.testObject_NewConv_user_1, "testObject_NewConv_v2_user_1.json"),
(Versioned @'V2 Test.Wire.API.Golden.Generated.NewConv_user.testObject_NewConv_user_3, "testObject_NewConv_v2_user_3.json")
],
testGroup "Golden: NewConv_user" $
testObjects
[ (Test.Wire.API.Golden.Generated.NewConv_user.testObject_NewConv_user_1, "testObject_NewConv_user_1.json"),
Expand All @@ -401,13 +413,13 @@ tests =
"testObject_ConversationList_20_28Id_20_2a_20C_29_user_2.json"
)
],
testGroup "Golden: ConversationList_20Conversation_user" $
testGroup "Golden: ConversationList_20Conversation_user V2" $
testObjects
[ ( Test.Wire.API.Golden.Generated.ConversationList_20Conversation_user.testObject_ConversationList_20Conversation_user_1,
"testObject_ConversationList_20Conversation_user_1.json"
[ ( Versioned @'V2 Test.Wire.API.Golden.Generated.ConversationList_20Conversation_user.testObject_ConversationList_20Conversation_user_1,
"testObject_ConversationList_20Conversation_v2_user_1.json"
),
( Test.Wire.API.Golden.Generated.ConversationList_20Conversation_user.testObject_ConversationList_20Conversation_user_2,
"testObject_ConversationList_20Conversation_user_2.json"
( Versioned @'V2 Test.Wire.API.Golden.Generated.ConversationList_20Conversation_user.testObject_ConversationList_20Conversation_user_2,
"testObject_ConversationList_20Conversation_v2_user_2.json"
)
],
testGroup "Golden: Access_user" $
Expand Down Expand Up @@ -450,6 +462,15 @@ tests =
"testObject_ConversationRename_user_1.json"
)
],
testGroup "Golden: ConversationAccessData_user V2" $
testObjects
[ ( Versioned @'V2 Test.Wire.API.Golden.Generated.ConversationAccessData_user.testObject_ConversationAccessData_user_1,
"testObject_ConversationAccessData_v2_user_1.json"
),
( Versioned @'V2 Test.Wire.API.Golden.Generated.ConversationAccessData_user.testObject_ConversationAccessData_user_2,
"testObject_ConversationAccessData_v2_user_2.json"
)
],
testGroup "Golden: ConversationAccessData_user" $
testObjects
[ ( Test.Wire.API.Golden.Generated.ConversationAccessData_user.testObject_ConversationAccessData_user_1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"access": [],
"access_role": "non_activated",
"access_role_v2": [
"access_role": [
"team_member",
"guest",
"service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"access": [
"invite"
],
"access_role": "non_activated",
"access_role_v2": [
"access_role": [
"team_member",
"guest"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"access": [],
"access_role": "non_activated",
"access_role_v2": [
"team_member",
"guest",
"service"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"access": [
"invite"
],
"access_role": "non_activated",
"access_role_v2": [
"team_member",
"guest"
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"access": [],
"access_role": "private",
"access_role_v2": [],
"access_role": [],
"creator": "00000001-0000-0001-0000-000200000001",
"id": "00000001-0000-0000-0000-000000000000",
"last_event": "0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"private",
"invite"
],
"access_role": "non_activated",
"access_role_v2": [
"access_role": [
"team_member",
"guest",
"service"
Expand Down
40 changes: 40 additions & 0 deletions libs/wire-api/test/golden/testObject_Conversation_v2_user_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"access": [],
"access_role": "private",
"access_role_v2": [],
"creator": "00000001-0000-0001-0000-000200000001",
"id": "00000001-0000-0000-0000-000000000000",
"last_event": "0.0",
"last_event_time": "1970-01-01T00:00:00.000Z",
"members": {
"others": [],
"self": {
"conversation_role": "rhhdzf0j0njilixx0g0vzrp06b_5us",
"hidden": false,
"hidden_ref": "",
"id": "00000001-0000-0001-0000-000100000000",
"otr_archived": false,
"otr_archived_ref": "",
"otr_muted_ref": null,
"otr_muted_status": null,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000001-0000-0001-0000-000100000000"
},
"service": null,
"status": 0,
"status_ref": "0.0",
"status_time": "1970-01-01T00:00:00.000Z"
}
},
"message_timer": null,
"name": " 0",
"protocol": "proteus",
"qualified_id": {
"domain": "golden.example.com",
"id": "00000001-0000-0000-0000-000000000000"
},
"receipt_mode": -2,
"team": "00000001-0000-0001-0000-000100000002",
"type": 2
}
71 changes: 71 additions & 0 deletions libs/wire-api/test/golden/testObject_Conversation_v2_user_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"access": [
"invite",
"invite",
"code",
"link",
"invite",
"private",
"link",
"code",
"code",
"link",
"private",
"invite"
],
"access_role": "non_activated",
"access_role_v2": [
"team_member",
"guest",
"service"
],
"creator": "00000000-0000-0000-0000-000200000001",
"id": "00000000-0000-0000-0000-000000000002",
"last_event": "0.0",
"last_event_time": "1970-01-01T00:00:00.000Z",
"members": {
"others": [
{
"conversation_role": "r1rg526serx51g15n99y1bw_9q0qrcwck3jxl7ocjsjqcoux7d1zbkz9nnczy92t2oyogxrx3cyh_b8yv44l61mx9uzdnv6",
"id": "00000001-0000-0001-0000-000100000001",
"qualified_id": {
"domain": "golden.example.com",
"id": "00000001-0000-0001-0000-000100000001"
},
"service": {
"id": "00000001-0000-0000-0000-000000000000",
"provider": "00000001-0000-0000-0000-000000000001"
},
"status": 0
}
],
"self": {
"conversation_role": "9b2d3thyqh4ptkwtq2n2v9qsni_ln1ca66et_z8dlhfs9oamp328knl3rj9kcj",
"hidden": true,
"hidden_ref": "",
"id": "00000000-0000-0001-0000-000100000001",
"otr_archived": false,
"otr_archived_ref": null,
"otr_muted_ref": null,
"otr_muted_status": -1,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0001-0000-000100000001"
},
"service": null,
"status": 0,
"status_ref": "0.0",
"status_time": "1970-01-01T00:00:00.000Z"
}
},
"message_timer": 1319272593797015,
"name": "",
"protocol": "proteus",
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0000-0000-000000000002"
},
"receipt_mode": null,
"team": null,
"type": 1
}
3 changes: 1 addition & 2 deletions libs/wire-api/test/golden/testObject_Event_user_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"invite",
"link"
],
"access_role": "non_activated",
"access_role_v2": [
"access_role": [
"team_member",
"guest"
]
Expand Down
3 changes: 1 addition & 2 deletions libs/wire-api/test/golden/testObject_Event_user_8.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"invite",
"link"
],
"access_role": "non_activated",
"access_role_v2": [
"access_role": [
"team_member",
"guest",
"service"
Expand Down
10 changes: 5 additions & 5 deletions libs/wire-api/test/golden/testObject_InvitationList_team_15.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"phone": "+872574694",
"role": "admin",
"team": "00000000-0000-0001-0000-000100000000",
"url" :null
"url": null
},
{
"created_at": "1864-05-09T23:06:13.648Z",
Expand All @@ -21,7 +21,7 @@
"phone": "+143031479742",
"role": "partner",
"team": "00000000-0000-0001-0000-000000000001",
"url" :null
"url": null
},
{
"created_at": "1864-05-09T10:37:03.809Z",
Expand All @@ -32,7 +32,7 @@
"phone": "+236346166386230",
"role": "partner",
"team": "00000001-0000-0000-0000-000000000000",
"url" :null
"url": null
},
{
"created_at": "1864-05-09T04:46:03.504Z",
Expand All @@ -43,7 +43,7 @@
"phone": "+80162248",
"role": "admin",
"team": "00000001-0000-0001-0000-000100000001",
"url" :null
"url": null
},
{
"created_at": "1864-05-09T12:53:52.047Z",
Expand All @@ -54,7 +54,7 @@
"phone": null,
"role": "owner",
"team": "00000000-0000-0001-0000-000100000001",
"url" :null
"url": null
}
]
}
3 changes: 1 addition & 2 deletions libs/wire-api/test/golden/testObject_NewConv_user_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"private",
"invite"
],
"access_role": "non_activated",
"access_role_v2": [
"access_roles": [
"team_member",
"guest"
],
Expand Down
3 changes: 1 addition & 2 deletions libs/wire-api/test/golden/testObject_NewConv_user_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"link",
"code"
],
"access_role": "non_activated",
"access_role_v2": [
"access_roles": [
"team_member",
"guest"
],
Expand Down
Loading

0 comments on commit bd078bb

Please sign in to comment.