NOISSUE - Add property based testing to users service (#2087)

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
This commit is contained in:
b1ackd0t
2024-03-22 18:16:07 +03:00
committed by GitHub
parent f733147517
commit 70c3d65863
38 changed files with 523 additions and 265 deletions
+283 -4
View File
@@ -34,6 +34,7 @@ tags:
paths:
/users:
post:
operationId: createUser
tags:
- Users
summary: Registers user account
@@ -49,14 +50,19 @@ paths:
description: Failed due to malformed JSON.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"409":
description: Failed due to using an existing identity.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
get:
operationId: listUsers
tags:
- Users
summary: List users
@@ -93,6 +99,7 @@ paths:
/users/profile:
get:
operationId: getProfile
summary: Gets info on currently logged in user.
description: |
Gets info on currently logged in user. Info is obtained using
@@ -113,6 +120,7 @@ paths:
/users/{userID}:
get:
operationId: getUser
summary: Retrieves a user
description: |
Retrieves a specific user that is identifier by the user ID.
@@ -129,6 +137,8 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"422":
@@ -137,6 +147,7 @@ paths:
$ref: "#/components/responses/ServiceError"
patch:
operationId: updateUser
summary: Updates name and metadata of the user.
description: |
Updates name and metadata of the user with provided ID. Name and metadata
@@ -154,15 +165,24 @@ paths:
$ref: "#/components/responses/UserRes"
"400":
description: Failed due to malformed JSON.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Failed due to non existing user.
"401":
description: Missing or invalid access token provided.
"409":
description: Failed due to using an existing identity.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/users/{userID}/tags:
patch:
operationId: updateUserTags
summary: Updates tags the user.
description: |
Updates tags of the user with provided ID. Tags is updated using
@@ -180,15 +200,22 @@ paths:
$ref: "#/components/responses/UserRes"
"400":
description: Failed due to malformed JSON.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Failed due to non existing user.
"401":
description: Missing or invalid access token provided.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/users/{userID}/identity:
patch:
operationId: updateUserIdentity
summary: Updates Identity of the user.
description: |
Updates identity of the user with provided ID. Identity is
@@ -206,15 +233,24 @@ paths:
$ref: "#/components/responses/UserRes"
"400":
description: Failed due to malformed JSON.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Failed due to non existing user.
"401":
description: Missing or invalid access token provided.
"409":
description: Failed due to using an existing identity.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/users/{userID}/role:
patch:
operationId: updateUserRole
summary: Updates the user role.
description: |
Updates role for the user with provided ID.
@@ -231,15 +267,22 @@ paths:
$ref: "#/components/responses/UserRes"
"400":
description: Failed due to malformed JSON.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Failed due to non existing user.
"401":
description: Missing or invalid access token provided.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/users/{userID}/disable:
post:
operationId: disableUser
summary: Disables a user
description: |
Disables a specific user that is identifier by the user ID.
@@ -256,8 +299,14 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"409":
description: Failed due to already disabled user.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
@@ -265,6 +314,7 @@ paths:
/users/{userID}/enable:
post:
operationId: enableUser
summary: Enables a user
description: |
Enables a specific user that is identifier by the user ID.
@@ -281,8 +331,14 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"409":
description: Failed due to already enabled user.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
@@ -290,6 +346,7 @@ paths:
/users/secret:
patch:
operationId: updateUserSecret
summary: Updates Secret of currently logged in user.
description: |
Updates secret of currently logged in user. Secret is updated using
@@ -305,15 +362,20 @@ paths:
$ref: "#/components/responses/UserRes"
"400":
description: Failed due to malformed JSON.
"404":
description: Failed due to non existing user.
"401":
description: Missing or invalid access token provided.
"404":
description: Failed due to non existing user.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/password/reset-request:
post:
operationId: requestPasswordReset
summary: User password reset request
description: |
Generates a reset token and sends and
@@ -331,11 +393,14 @@ paths:
description: Failed due to malformed JSON.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/password/reset:
put:
operationId: resetPassword
summary: User password reset endpoint
description: |
When user gets reset token, after he submitted
@@ -350,13 +415,18 @@ paths:
description: User link .
"400":
description: Failed due to malformed JSON.
"401":
description: Missing or invalid access token provided.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/groups/{groupID}/users:
get:
operationId: listUsersInGroup
tags:
- Users
summary: List users in a group
@@ -383,6 +453,8 @@ paths:
description: |
Missing or invalid access token provided.
This endpoint is available only for administrators.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"422":
@@ -392,6 +464,7 @@ paths:
/channels/{channelID}/users:
get:
operationId: listUsersInChannel
tags:
- Users
summary: List users in a channel
@@ -418,6 +491,8 @@ paths:
description: |
Missing or invalid access token provided.
This endpoint is available only for administrators.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"422":
@@ -427,6 +502,7 @@ paths:
/users/tokens/issue:
post:
operationId: issueToken
summary: Issue Token
description: |
Issue Access and Refresh Token used for authenticating into the system.
@@ -437,8 +513,12 @@ paths:
responses:
"200":
$ref: "#/components/responses/TokenRes"
"400":
description: Failed due to malformed JSON.
"404":
description: A non-existent entity request.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
@@ -446,6 +526,7 @@ paths:
/users/tokens/refresh:
post:
operationId: refreshToken
summary: Refresh Token
description: |
Refreshes Access and Refresh Token used for authenticating into the system.
@@ -456,8 +537,12 @@ paths:
responses:
"200":
$ref: "#/components/responses/TokenRes"
"400":
description: Failed due to malformed JSON.
"404":
description: A non-existent entity request.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
@@ -465,6 +550,7 @@ paths:
/groups:
post:
operationId: createGroup
tags:
- Groups
summary: Creates new group
@@ -482,14 +568,19 @@ paths:
description: Failed due to malformed JSON.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"409":
description: Failed due to using an existing identity.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
get:
operationId: listGroups
summary: Lists groups.
description: |
Lists groups up to a max level of hierarchy that can be fetched in one
@@ -515,13 +606,18 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Group does not exist.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/groups/{groupID}:
get:
operationId: getGroup
summary: Gets group info.
description: |
Gets info on a group specified by id.
@@ -538,12 +634,17 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Group does not exist.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
put:
operationId: updateGroup
summary: Updates group data.
description: |
Updates Name, Description or Metadata of a group.
@@ -562,8 +663,16 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Group does not exist.
"409":
description: Failed due to using an existing identity.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
delete:
@@ -589,6 +698,7 @@ paths:
/groups/{groupID}/children:
get:
operationId: listChildren
summary: List children of a certain group
description: |
Lists groups up to a max level of hierarchy that can be fetched in one
@@ -615,13 +725,18 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Group does not exist.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/groups/{groupID}/parents:
get:
operationId: listParents
summary: List parents of a certain group
description: |
Lists groups up to a max level of hierarchy that can be fetched in one
@@ -648,13 +763,18 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Group does not exist.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/groups/{groupID}/enable:
post:
operationId: enableGroup
summary: Enables a group
description: |
Enables a specific group that is identifier by the group ID.
@@ -671,8 +791,14 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"409":
description: Failed due to already enabled group.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
@@ -680,6 +806,7 @@ paths:
/groups/{groupID}/disable:
post:
operationId: disableGroup
summary: Disables a group
description: |
Disables a specific group that is identifier by the group ID.
@@ -696,8 +823,14 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"409":
description: Failed due to already disabled group.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
@@ -705,6 +838,7 @@ paths:
/groups/{groupID}/users/assign:
post:
operationId: assignUser
summary: Assigns a user to a group
description: |
Assigns a specific user to a group that is identifier by the group ID.
@@ -723,8 +857,12 @@ paths:
description: Failed due to malformed group's ID.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
@@ -732,6 +870,7 @@ paths:
/groups/{groupID}/users/unassign:
post:
operationId: unassignUser
summary: Unassigns a user to a group
description: |
Unassigns a specific user to a group that is identifier by the group ID.
@@ -750,8 +889,12 @@ paths:
description: Failed due to malformed group's ID.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: A non-existent entity request.
"415":
description: Missing or invalid content type.
"422":
description: Database can't process request.
"500":
@@ -759,6 +902,7 @@ paths:
/channels/{memberID}/groups:
get:
operationId: listGroupsInChannel
summary: Get group associated with the member
description: |
Gets groups associated with the channel member specified by id.
@@ -780,13 +924,18 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Group does not exist.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/users/{memberID}/groups:
get:
operationId: listGroupsByUser
summary: Get group associated with the member
description: |
Gets groups associated with the user member specified by id.
@@ -808,8 +957,12 @@ paths:
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"403":
description: Failed to perform authorization over the entity.
"404":
description: Group does not exist.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/domains/{domainID}/users:
@@ -845,6 +998,7 @@ paths:
$ref: "#/components/responses/ServiceError"
/health:
get:
operationId: health
summary: Retrieves service health check info.
tags:
- health
@@ -1128,7 +1282,7 @@ components:
required:
- groups
- total
- level
- offset
MembersPage:
type: object
@@ -1212,7 +1366,7 @@ components:
properties:
role:
type: string
enum: ["admin","user"]
enum: ["admin", "user"]
example: user
description: User role example.
required:
@@ -1351,6 +1505,9 @@ components:
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
pattern: "^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
required: true
example: bb7edb32-2eac-4aad-aebe-ed96fe073879
@@ -1369,6 +1526,7 @@ components:
in: query
schema:
type: string
pattern: "^[^\u0000-\u001F]*$"
required: false
example: "admin@example.com"
@@ -1429,6 +1587,9 @@ components:
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
pattern: "^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
required: true
example: bb7edb32-2eac-4aad-aebe-ed96fe073879
@@ -1439,6 +1600,9 @@ components:
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
pattern: "^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
required: true
example: bb7edb32-2eac-4aad-aebe-ed96fe073879
@@ -1449,6 +1613,9 @@ components:
schema:
type: string
format: uuid
minLength: 36
maxLength: 36
pattern: "^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
required: true
example: bb7edb32-2eac-4aad-aebe-ed96fe073879
@@ -1667,6 +1834,43 @@ components:
application/json:
schema:
$ref: "#/components/schemas/User"
links:
get:
operationId: getUser
parameters:
userID: $response.body#/id
get_groups:
operationId: listUsersInGroup
parameters:
groupID: $response.body#/id
get_channels:
operationId: listUsersInChannel
parameters:
channelID: $response.body#/id
update:
operationId: updateUser
parameters:
userID: $response.body#/id
update_tags:
operationId: updateUserTags
parameters:
userID: $response.body#/id
update_identity:
operationId: updateUserIdentity
parameters:
userID: $response.body#/id
update_role:
operationId: updateUserRole
parameters:
userID: $response.body#/id
disable:
operationId: disableUser
parameters:
userID: $response.body#/id
enable:
operationId: enableUser
parameters:
userID: $response.body#/id
UserRes:
description: Data retrieved.
@@ -1674,6 +1878,15 @@ components:
application/json:
schema:
$ref: "#/components/schemas/User"
links:
get_groups:
operationId: listUsersInGroup
parameters:
groupID: $response.body#/id
get_channels:
operationId: listUsersInChannel
parameters:
channelID: $response.body#/id
UserPageRes:
description: Data retrieved.
@@ -1694,6 +1907,47 @@ components:
application/json:
schema:
$ref: "#/components/schemas/Group"
links:
get:
operationId: getGroup
parameters:
groupID: $response.body#/id
get_children:
operationId: listChildren
parameters:
groupID: $response.body#/id
get_parent:
operationId: listParents
parameters:
groupID: $response.body#/id
get_channels:
operationId: listGroupsInChannel
parameters:
memberID: $response.body#/id
get_users:
operationId: listGroupsByUser
parameters:
memberID: $response.body#/id
update:
operationId: updateGroup
parameters:
groupID: $response.body#/id
disable:
operationId: disableGroup
parameters:
groupID: $response.body#/id
enable:
operationId: enableGroup
parameters:
groupID: $response.body#/id
assign:
operationId: assignUser
parameters:
groupID: $response.body#/id
unassign:
operationId: unassignUser
parameters:
groupID: $response.body#/id
GroupRes:
description: Data retrieved.
@@ -1701,6 +1955,31 @@ components:
application/json:
schema:
$ref: "#/components/schemas/Group"
links:
get_children:
operationId: listChildren
parameters:
groupID: $response.body#/id
get_parent:
operationId: listParents
parameters:
groupID: $response.body#/id
get_channels:
operationId: listGroupsInChannel
parameters:
memberID: $response.body#/id
get_users:
operationId: listGroupsByUser
parameters:
memberID: $response.body#/id
assign:
operationId: assignUser
parameters:
groupID: $response.body#/id
unassign:
operationId: unassignUser
parameters:
groupID: $response.body#/id
GroupPageRes:
description: Data retrieved.