Files
workavia-drive/twake/backend/node/test/http/private-channels-membership.http
T
montaghanmy 10fe6f78d1 feat: init
2023-03-23 11:03:16 +01:00

109 lines
2.8 KiB
HTTP

@company_id = bcfe2f79-8e81-42a3-b551-3a32d49b2b4c
@workspace_id = 3328552c-5ccd-4172-b84a-d876d56aa71b
@baseURL = http://localhost:3000
@channelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/{{workspace_id}}
@directChannelsURL = {{baseURL}}/internal/services/channels/v1/companies/{{company_id}}/workspaces/direct
### Login as user 1
# @name login
GET {{baseURL}}/api/auth/login
@authTokenUser1 = {{login.response.body.token}}
@currentUserId1 = {{login.response.body.user.id}}
### Login as user 2
# @name login2
GET {{baseURL}}/api/auth/login
@authTokenUser2 = {{login2.response.body.token}}
@currentUserId2 = {{login2.response.body.user.id}}
### User 1 creates a private channel
# @name createChannel
POST {{channelsURL}}/channels
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
{
"resource": {
"name": "My private channel",
"icon": "twake logo",
"description": "This channel allow twake's team to chat easily",
"channel_group": "twake",
"visibility": "private",
"is_default": true,
"archived": false
}
}
### Get the private channel
@getId = {{createChannel.response.body.resource.id}}
GET {{channelsURL}}/channels/{{getId}}
Authorization: Bearer {{authTokenUser1}}
### Get all channel members
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### The user 2 tries to join the private channel, this should reject
POST {{channelsURL}}/channels/{{getId}}/members
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
{
"resource": {
"user_id": "{{currentUserId2}}"
}
}
### The user 1 adds the user 2 as channel member, this should be OK
POST {{channelsURL}}/channels/{{getId}}/members
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
{
"resource": {
"user_id": "{{currentUserId2}}"
}
}
### User 2 lists his channels
GET {{channelsURL}}/channels?websockets=true&mine=true&limit=5
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
### Get all channel members as user 1
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### Get all channel members as user 2
GET {{channelsURL}}/channels/{{getId}}/members?websockets=true
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}
### User 1 leaves the channel he created
DELETE {{channelsURL}}/channels/{{getId}}/members/{{currentUserId1}}
Content-Type: application/json
Authorization: Bearer {{authTokenUser1}}
### User 2 leaves the channel: Error since he is the last member, he can not leave
DELETE {{channelsURL}}/channels/{{getId}}/members/{{currentUserId2}}
Content-Type: application/json
Authorization: Bearer {{authTokenUser2}}