Skip to content

Commit

Permalink
Misc Cleanup (#748)
Browse files Browse the repository at this point in the history
* misc cleanup
* Update user seed file
  • Loading branch information
NickPhura authored Apr 25, 2022
1 parent f5cd391 commit 0ba1daa
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sonar.projectVersion=Autoscan

# Path to sources
sonar.sources=app/src,api/src
sonar.exclusions=**/*.test.*,**/*.spec.*,**/__tests__/**,**/__snapshots__/**,**/constants/**,**/shared-api-docs.ts
sonar.exclusions=**/*.test.*,**/*.spec.*,**/__tests__/**,**/__snapshots__/**,**/__mocks__/**,**/constants/**,**/shared-api-docs.ts
#sonar.inclusions=

# Path to tests
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ The objectives for the SIMS project are:

### Windows

_Note: there are 2 mutually exclusive modes that Docker Desktop supports on Windows: Hyper-V or WSL2. You should be able to run the application in either mode, but this documentation was only written with instructions for Hyper-V. See https://code.visualstudio.com/blogs/2020/03/02/docker-in-wsl2 for possible instructions on using Docker Desktop in WSL2._

If prompted, install Docker using Hyper-V (not WSL 2)

### Grant Docker access to your local folders

This setup for SIMS uses volumes to support live reload.
To leverage live reload you will need to ensure Docker is running using Hyper-V (not the WSL2 engine).
This setup uses volumes to support live reload.
Ensure Docker Desktop has access to your file system so that it can detect file changes and trigger live reload.

#### MacOS

Expand Down Expand Up @@ -113,7 +115,7 @@ make env
Result of running `make env` for the first time:
![make env screenshot](readme_screenshots/running_make_env.png "Running `make env`")

## Start all SIMS Applications
## Start all Applications

Starts all applications (database, api, app, and n8n).

Expand Down Expand Up @@ -160,7 +162,7 @@ make install

## Delete All Containers

Will stop and delete the sims docker containers.
Will stop and delete the application docker containers.
This is useful when you want to clear out all database content, returning it to its initial default state.
After you've run `make clean`, running `make web` will launch new containers, with a fresh instance of the database.

Expand Down Expand Up @@ -326,7 +328,6 @@ _Note: all of the above connection values can be found in the `.env` file_

[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-black.svg)](https://sonarcloud.io/dashboard?id=bcgov_biohubbc)


# License

Copyright 2019 Province of British Columbia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sinonChai from 'sinon-chai';
import SQL from 'sql-template-strings';
import * as db from '../../../../../database/db';
import { HTTPError } from '../../../../../errors/custom-error';
import * as queries from '../../../../../queries/queries';
import { queries } from '../../../../../queries/queries';
import { ProjectService } from '../../../../../services/project-service';
import { getMockDBConnection, getRequestHandlerMocks } from '../../../../../__mocks__/db';
import * as doAllProjectsHaveAProjectLead from '../../../../user/{userId}/delete';
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('Delete a project participant.', () => {

mockReq.params = { projectId: '1', projectParticipationId: '2' };

sinon.stub(queries.queries.projectParticipation, 'deleteProjectParticipationSQL').returns(null);
sinon.stub(queries.projectParticipation, 'deleteProjectParticipationSQL').returns(null);
sinon.stub(ProjectService.prototype, 'getProjectParticipants').resolves([{ id: 1 }]);
sinon.stub(doAllProjectsHaveAProjectLead, 'doAllProjectsHaveAProjectLead').returns(true);

Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Delete a project participant.', () => {

mockReq.params = { projectId: '1', projectParticipationId: '2' };

sinon.stub(queries.queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
sinon.stub(queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
sinon.stub(ProjectService.prototype, 'getProjectParticipants').resolves([{ id: 1 }]);
sinon.stub(doAllProjectsHaveAProjectLead, 'doAllProjectsHaveAProjectLead').returns(true);

Expand Down Expand Up @@ -119,7 +119,7 @@ describe('Delete a project participant.', () => {

mockReq.params = { projectId: '1', projectParticipationId: '2' };

sinon.stub(queries.queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
sinon.stub(queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
const getProjectParticipant = sinon.stub(ProjectService.prototype, 'getProjectParticipants');
const doAllProjectsHaveLead = sinon.stub(doAllProjectsHaveAProjectLead, 'doAllProjectsHaveAProjectLead');

Expand Down Expand Up @@ -162,7 +162,7 @@ describe('Delete a project participant.', () => {

mockReq.params = { projectId: '1', projectParticipationId: '2' };

sinon.stub(queries.queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
sinon.stub(queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
const getProjectParticipant = sinon.stub(ProjectService.prototype, 'getProjectParticipants');
const doAllProjectsHaveLead = sinon.stub(doAllProjectsHaveAProjectLead, 'doAllProjectsHaveAProjectLead');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sinonChai from 'sinon-chai';
import SQL from 'sql-template-strings';
import * as db from '../../../../../database/db';
import { HTTPError } from '../../../../../errors/custom-error';
import * as queries from '../../../../../queries/queries';
import { queries } from '../../../../../queries/queries';
import { ProjectService } from '../../../../../services/project-service';
import { getMockDBConnection, getRequestHandlerMocks } from '../../../../../__mocks__/db';
import * as doAllProjectsHaveAProjectLead from '../../../../user/{userId}/delete';
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('Delete a project participant.', () => {
mockReq.params = { projectId: '1', projectParticipationId: '2' };
mockReq.body = { roleId: '1' };

sinon.stub(queries.queries.projectParticipation, 'deleteProjectParticipationSQL').returns(null);
sinon.stub(queries.projectParticipation, 'deleteProjectParticipationSQL').returns(null);
sinon.stub(ProjectService.prototype, 'getProjectParticipants').resolves([{ id: 1 }]);
sinon.stub(doAllProjectsHaveAProjectLead, 'doAllProjectsHaveAProjectLead').returns(true);

Expand Down Expand Up @@ -111,7 +111,7 @@ describe('Delete a project participant.', () => {
mockReq.params = { projectId: '1', projectParticipationId: '2' };
mockReq.body = { roleId: '1' };

sinon.stub(queries.queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
sinon.stub(queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
sinon.stub(ProjectService.prototype, 'getProjectParticipants').resolves([{ id: 1 }]);
sinon.stub(doAllProjectsHaveAProjectLead, 'doAllProjectsHaveAProjectLead').returns(true);

Expand Down Expand Up @@ -140,7 +140,7 @@ describe('Delete a project participant.', () => {
mockReq.params = { projectId: '1', projectParticipationId: '2' };
mockReq.body = { roleId: '1' };

sinon.stub(queries.queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
sinon.stub(queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
const getProjectParticipant = sinon.stub(ProjectService.prototype, 'getProjectParticipants');
const doAllProjectsHaveLead = sinon.stub(doAllProjectsHaveAProjectLead, 'doAllProjectsHaveAProjectLead');

Expand Down Expand Up @@ -184,7 +184,7 @@ describe('Delete a project participant.', () => {
mockReq.params = { projectId: '1', projectParticipationId: '2' };
mockReq.body = { roleId: '1' };

sinon.stub(queries.queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
sinon.stub(queries.projectParticipation, 'deleteProjectParticipationSQL').returns(SQL`some query`);
const getProjectParticipant = sinon.stub(ProjectService.prototype, 'getProjectParticipants');
const doAllProjectsHaveLead = sinon.stub(doAllProjectsHaveAProjectLead, 'doAllProjectsHaveAProjectLead');

Expand Down
30 changes: 15 additions & 15 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"formik": "~2.2.6",
"keycloak-js": "~9.0.2",
"leaflet": "~1.7.1",
"leaflet-draw": "~1.0.0",
"leaflet-draw": "~1.0.4",
"leaflet-fullscreen": "~1.0.2",
"leaflet.locatecontrol": "~0.72.0",
"leaflet.locatecontrol": "~0.76.0",
"lodash-es": "~4.17.21",
"moment": "~2.29.2",
"node-sass": "~4.14.1",
Expand Down
72 changes: 38 additions & 34 deletions database/src/seeds/01_db_system_users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,31 @@ export enum SYSTEM_IDENTITY_SOURCE {
BCEID = 'BCEID'
}

export enum SYSTEM_USER_ROLE_ID {
SYSTEM_ADMINISTRATOR = 1,
CREATOR = 2,
DATA_ADMINISTRATOR = 3
}

const systemUsers = [
{ identifier: 'aagahche', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'cgarrett', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'istest1', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'jrpopkin', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'jxdunsdo', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'mbaerg', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'nphura', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'postman', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 2 },
{ identifier: 'robmunro', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'rstens', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'tadekens', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'test1', type: SYSTEM_IDENTITY_SOURCE.BCEID, roleId: 1 },
{ identifier: 'test2', type: SYSTEM_IDENTITY_SOURCE.BCEID, roleId: 1 },
{ identifier: 'test3', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'test4', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 2 },
{ identifier: 'test5', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 2 },
{ identifier: 'test6', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 6 },
{ identifier: 'test7', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 6 },
{ identifier: 'cypress', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 },
{ identifier: 'keinarss', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: 1 }
{ identifier: 'aagahche', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'cgarrett', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'cupshall', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'jxdunsdo', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'keinarss', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'mbaerg', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'nphura', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'robmunro', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'rstens', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'zochampi', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'test1', type: SYSTEM_IDENTITY_SOURCE.BCEID, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'test2', type: SYSTEM_IDENTITY_SOURCE.BCEID, roleId: SYSTEM_USER_ROLE_ID.CREATOR },
{ identifier: 'test3', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'test4', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR },
{ identifier: 'test5', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.DATA_ADMINISTRATOR },
{ identifier: 'test6', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.CREATOR },
{ identifier: 'test7', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.CREATOR },
{ identifier: 'cypress', type: SYSTEM_IDENTITY_SOURCE.IDIR, roleId: SYSTEM_USER_ROLE_ID.SYSTEM_ADMINISTRATOR }
];

/**
Expand Down Expand Up @@ -70,12 +74,12 @@ export async function seed(knex: Knex): Promise<void> {
* @param {string} userIdentifier
*/
const getSystemUserSQL = (userIdentifier: string) => `
SELECT
user_identifier
FROM
system_user
WHERE
user_identifier = '${userIdentifier}';
SELECT
user_identifier
FROM
system_user
WHERE
user_identifier = '${userIdentifier}';
`;

/**
Expand Down Expand Up @@ -113,11 +117,11 @@ const insertSystemUserSQL = (userIdentifier: string, userType: string) => `
* @param {number} roleId
*/
const insertSystemUserRoleSQL = (userIdentifier: string, roleId: number) => `
INSERT INTO system_user_role (
system_user_id,
system_role_id
) VALUES (
(SELECT system_user_id from system_user where user_identifier = '${userIdentifier}'),
${roleId}
);
`;
INSERT INTO system_user_role (
system_user_id,
system_role_id
) VALUES (
(SELECT system_user_id from system_user where user_identifier = '${userIdentifier}'),
${roleId}
);
`;
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ services:
- /opt/app-root/src/node_modules # prevents local node_modules overriding container node_modules
networks:
- local-network
depends_on:
- api

## Run the database migrations and seeding
db_setup:
Expand Down

0 comments on commit 0ba1daa

Please sign in to comment.