Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev -> QA #193

Merged
merged 10 commits into from
Mar 20, 2024
4 changes: 4 additions & 0 deletions src/build/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ const models: TsoaRoute.Models = {
"requestStatus": {"ref":"requestStatusType","required":true},
"rejectionReason": {"dataType":"string","required":true},
"createdAt": {"dataType":"string","required":true},
"updatedAt": {"dataType":"string","required":true},
"updatedBy": {"dataType":"string","required":true},
},
"additionalProperties": false,
},
Expand Down Expand Up @@ -454,6 +456,7 @@ const models: TsoaRoute.Models = {
"isActive": {"dataType":"boolean","required":true},
"deactivationReason": {"dataType":"string","required":true},
"updatedAt": {"dataType":"union","subSchemas":[{"dataType":"string"},{"dataType":"enum","enums":[null]}],"required":true},
"updatedBy": {"dataType":"union","subSchemas":[{"dataType":"string"},{"dataType":"enum","enums":[null]}],"required":true},
},
"additionalProperties": false,
},
Expand Down Expand Up @@ -482,6 +485,7 @@ const models: TsoaRoute.Models = {
"userName": {"dataType":"string","required":true},
"givenName": {"dataType":"string","required":true},
"lastName": {"dataType":"string","required":true},
"updatedBy": {"dataType":"string","required":true},
},
"additionalProperties": false,
},
Expand Down
53 changes: 34 additions & 19 deletions src/build/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@
},
"createdAt": {
"type": "string"
},
"updatedAt": {
"type": "string"
},
"updatedBy": {
"type": "string"
}
},
"required": [
Expand All @@ -272,7 +278,9 @@
"requestReason",
"requestStatus",
"rejectionReason",
"createdAt"
"createdAt",
"updatedAt",
"updatedBy"
],
"type": "object",
"additionalProperties": false
Expand Down Expand Up @@ -1171,6 +1179,10 @@
"updatedAt": {
"type": "string",
"nullable": true
},
"updatedBy": {
"type": "string",
"nullable": true
}
},
"required": [
Expand All @@ -1185,24 +1197,11 @@
"lastName",
"isActive",
"deactivationReason",
"updatedAt"
"updatedAt",
"updatedBy"
],
"type": "object",
"additionalProperties": false,
"example": {
"userId": "82dc08e5-cbca-40c2-9d35-a4d1407d5f8d",
"userGuid": "A84D1AB221334298956C47A7B623E983",
"identityType": "idir",
"role": "Admin",
"organization": "Bc Service",
"email": "abc@gov.ca",
"userName": "johndoe",
"givenName": "John",
"lastName": "Doe",
"isActive": true,
"deactivationReason": "To get access to site",
"updatedAt": "2023-08-25T15:12:59.764Z"
}
"additionalProperties": false
},
"noActiveUserFound": {
"description": "No active user found",
Expand Down Expand Up @@ -1257,6 +1256,9 @@
},
"lastName": {
"type": "string"
},
"updatedBy": {
"type": "string"
}
},
"required": [
Expand All @@ -1266,10 +1268,23 @@
"email",
"userName",
"givenName",
"lastName"
"lastName",
"updatedBy"
],
"type": "object",
"additionalProperties": false
"additionalProperties": false,
"example": {
"userId": "82dc08e5-cbca-40c2-9d35-a4d1407d5f8d",
"userGuid": "A84D1AB221334298956C47A7B623E983",
"identityType": "idir",
"role": "Admin",
"organization": "Bc Service",
"email": "abc@gov.ca",
"userName": "johndoe",
"givenName": "John",
"lastName": "Doe",
"updatedBy": "ABC123"
}
},
"userDeactivateRequestBody": {
"description": "Request body for deactivation of one or multiple users",
Expand Down
3 changes: 3 additions & 0 deletions src/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ export class UserController extends Controller {
...(existingUser[0].lastName !== requestBody.lastName && {
lastName: requestBody.lastName,
}),
...(existingUser[0].updatedBy !== requestBody.updatedBy && {
updatedBy: requestBody.updatedBy,
}),
};
await updateUser(userId, updateFields, requestBody);
} catch (err) {
Expand Down
7 changes: 6 additions & 1 deletion src/db/AccessRequest.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export async function updateRequestStatus(
idList.push(where);
}
if (action === requestStatusType.Granted) {
updateFields = { requestStatus: requestStatusType.Granted };
updateFields = {
requestStatus: requestStatusType.Granted,
updatedBy: username,
};
templateId = process.env.GC_NOTIFY_ACCESS_APPROVE_EMAIL_TEMPLATE_ID!;
}

Expand Down Expand Up @@ -177,6 +180,8 @@ export async function getRequestList(
requestReason: true,
rejectionReason: true,
createdAt: true,
updatedBy: true,
updatedAt: true,
},
where: where ? where : undefined,
order: { createdAt: 'ASC' as FindOptionsOrderValue },
Expand Down
1 change: 1 addition & 0 deletions src/db/Users.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function getUserList(where?: object): Promise<Users[] | any> {
isActive: true,
deactivationReason: true,
updatedAt: true,
updatedBy: true,
},
where: where ? where : undefined,
order: { createdAt: 'ASC' as FindOptionsOrderValue },
Expand Down
14 changes: 13 additions & 1 deletion src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ export interface accessRequestResponseBody {
"firstName": "John",
"lastName": "Doe",
"createdAt": ""2023-08-24T15:06:27.269Z",
"updatedAt": "2023-10-30T03:40:41.166Z",
"updatedBy": null,
"requestReason": "To get access to site",
"rejectionReason": "Information needed"
}
Expand All @@ -498,6 +500,8 @@ export interface accessRequest {
requestReason: string;
rejectionReason: string;
createdAt: string;
updatedAt: string;
updatedBy: string;
}

/**
Expand All @@ -515,6 +519,8 @@ export interface accessRequest {
"lastName": "Doe",
"requestStatus": "NotGranted",
"createdAt": ""2023-08-24T15:06:27.269Z",
"updatedAt": "2023-10-30T03:40:41.166Z",
"updatedBy": null,
"requestReason": "To get access to site",
"rejectionReason": "Information needed"
}
Expand All @@ -533,6 +539,8 @@ export interface accessRequestList {
requestStatus: requestStatusType;
rejectionReason: string;
createdAt: string;
updatedAt: string;
updatedBy: string;
}

/**
Expand Down Expand Up @@ -707,7 +715,8 @@ export interface noActiveUserFound {
"lastName": "Doe",
"isActive": true,
"deactivationReason": "To get access to site",
"updatedAt": "2023-08-25T15:12:59.764Z"
"updatedAt": "2023-08-25T15:12:59.764Z",
"updatedBy": "John Doe",
}
*/
export interface userList {
Expand All @@ -723,6 +732,7 @@ export interface userList {
isActive: boolean;
deactivationReason: string;
updatedAt: string | null;
updatedBy: string | null;
}

/**
Expand All @@ -741,6 +751,7 @@ export interface userList {
"userName": "johndoe",
"givenName": "John",
"lastName": "Doe",
"updatedBy": "ABC123"
}
*/
export interface userUpdateRequestBody {
Expand All @@ -751,6 +762,7 @@ export interface userUpdateRequestBody {
userName: string;
givenName: string;
lastName: string;
updatedBy: string;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/tests/commonResponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ export const UserUpdateRequestBody: userUpdateRequestBody = {
userId: '123',
userName: 'JohnDoe',
organization: 'BC Government',
updatedBy: 'ABC123',
};

export const UsersMultiResponse = [
Expand Down Expand Up @@ -1373,6 +1374,7 @@ export const UserListSuccess = [
lastName: 'Doe',
isActive: true,
updatedAt: '2023-08-25T15:12:59.764Z',
updatedBy: 'John Doe',
},
];

Expand All @@ -1390,6 +1392,7 @@ export const UserListSuccessDeactivated = [
isActive: false,
deactivationReason: 'Invalid user',
updatedAt: '2023-08-25T15:12:59.764Z',
updatedBy: 'John doe',
},
];

Expand All @@ -1401,6 +1404,7 @@ export const updateUserRequestBody = {
userName: 'username',
givenName: 'givenName',
lastName: 'string',
updatedBy: 'USERID',
};

export const updateUserExistingUser = [
Expand Down
Loading