Skip to content

Commit

Permalink
Merge branch 'dev' into 425-documents-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
MacQSL authored Jan 12, 2024
2 parents 4555a10 + a108222 commit 7f8b721
Show file tree
Hide file tree
Showing 16 changed files with 746 additions and 74 deletions.
3 changes: 2 additions & 1 deletion api/.pipeline/lib/api.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const apiDeploy = async (settings) => {
ELASTICSEARCH_TAXONOMY_INDEX: phases[phase].elasticsearchTaxonomyIndex,
// S3 (Object Store)
S3_KEY_PREFIX: phases[phase].s3KeyPrefix,
OBJECT_STORE_SECRETS: 'biohubbc-object-store',
// Database
TZ: phases[phase].tz,
DB_SERVICE_NAME: `${phases[phase].dbName}-postgresql${phases[phase].suffix}`,
Expand All @@ -60,7 +61,7 @@ const apiDeploy = async (settings) => {
KEYCLOAK_API_ENVIRONMENT: phases[phase].sso.cssApi.cssApiEnvironment,
// Log Level
LOG_LEVEL: phases[phase].logLevel || 'info',
// OPenshift Resources
// Openshift Resources
CPU_REQUEST: phases[phase].cpuRequest,
CPU_LIMIT: phases[phase].cpuLimit,
MEMORY_REQUEST: phases[phase].memoryRequest,
Expand Down
18 changes: 8 additions & 10 deletions api/.pipeline/lib/queue.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,21 @@ const queueDeploy = async (settings) => {
HOST: phases[phase].host,
CHANGE_ID: phases.build.changeId || changeId,
APP_HOST: phases[phase].appHost,
DB_SERVICE_NAME: `${phases[phase].dbName}-postgresql${phases[phase].suffix}`,
// Node
NODE_ENV: phases[phase].env || 'dev',
// Elastic Search
ELASTICSEARCH_URL: phases[phase].elasticsearchURL,
ELASTICSEARCH_EML_INDEX: phases[phase].elasticsearchEmlIndex,
ELASTICSEARCH_TAXONOMY_INDEX: phases[phase].elasticsearchTaxonomyIndex,
// S3 (Object Store)
S3_KEY_PREFIX: phases[phase].s3KeyPrefix,
TZ: phases[phase].tz,
KEYCLOAK_ADMIN_USERNAME: phases[phase].sso.adminUserName,
KEYCLOAK_SECRET: phases[phase].sso.keycloakSecret,
KEYCLOAK_SECRET_ADMIN_PASSWORD: phases[phase].sso.keycloakSecretAdminPassword,
KEYCLOAK_HOST: phases[phase].sso.url,
KEYCLOAK_CLIENT_ID: phases[phase].sso.clientId,
KEYCLOAK_REALM: phases[phase].sso.realm,
KEYCLOAK_INTEGRATION_ID: phases[phase].sso.integrationId,
KEYCLOAK_API_HOST: phases[phase].sso.apiHost,
OBJECT_STORE_SECRETS: 'biohubbc-object-store',
// Database
TZ: phases[phase].tz,
DB_SERVICE_NAME: `${phases[phase].dbName}-postgresql${phases[phase].suffix}`,
// Log Level
LOG_LEVEL: phases[phase].logLevel || 'info',
// Openshift Resources
CPU_REQUEST: phases[phase].cpuRequest,
CPU_LIMIT: phases[phase].cpuLimit,
MEMORY_REQUEST: phases[phase].memoryRequest,
Expand Down
3 changes: 0 additions & 3 deletions api/.pipeline/queue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const phases = {
elasticsearchTaxonomyIndex: 'taxonomy_3.0.0',
s3KeyPrefix: 'biohub',
tz: config.timezone.api,
sso: config.sso.dev,
logLevel: 'debug',
queueDockerfilePath: queueDockerfilePath,
cpuRequest: '100m',
Expand Down Expand Up @@ -116,7 +115,6 @@ const phases = {
elasticsearchTaxonomyIndex: 'taxonomy_3.0.0',
s3KeyPrefix: 'biohub',
tz: config.timezone.api,
sso: config.sso.test,
logLevel: 'info',
queueDockerfilePath: queueDockerfilePath,
cpuRequest: '200m',
Expand Down Expand Up @@ -144,7 +142,6 @@ const phases = {
elasticsearchTaxonomyIndex: 'taxonomy_3.0.0',
s3KeyPrefix: 'biohub',
tz: config.timezone.api,
sso: config.sso.prod,
logLevel: 'info',
queueDockerfilePath: queueDockerfilePath,
cpuRequest: '200m',
Expand Down
17 changes: 11 additions & 6 deletions api/.pipeline/templates/api.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ parameters:
- name: DB_SERVICE_NAME
description: 'Database service name associated with deployment'
required: true
# Node
- name: NODE_ENV
description: Application Environment type variable
required: true
value: 'dev'
- name: NODE_OPTIONS
# Elastic Search
- name: ELASTICSEARCH_URL
description: Platform Elasticsearch URL
required: true
Expand All @@ -48,10 +50,6 @@ parameters:
description: Platform Elasticsearch Taxonomy Index
required: true
vale: 'taxonomy_3.0.0'
- name: S3_KEY_PREFIX
description: S3 key optional prefix
required: false
value: 'biohub'
- name: TZ
description: Application timezone
required: false
Expand Down Expand Up @@ -99,9 +97,14 @@ parameters:
description: Api default port name
value: '6100-tcp'
# Object Store (S3)
- name: S3_KEY_PREFIX
description: S3 key optional prefix
required: false
value: 'biohub'
- name: OBJECT_STORE_SECRETS
description: Secrets used to read and write to the S3 storage
value: 'biohubbc-object-store'
# GC Notify
- name: GCNOTIFY_API_SECRET
description: Secret for gcnotify api key
value: 'gcnotify-api-key'
Expand All @@ -121,8 +124,10 @@ parameters:
value: https://api.notification.canada.ca/v2/notifications/email
- name: GCNOTIFY_SMS_URL
value: https://api.notification.canada.ca/v2/notifications/sms
# Log Level
- name: LOG_LEVEL
value: 'info'
# Openshift
- name: CPU_REQUEST
value: '100m'
- name: CPU_LIMIT
Expand Down Expand Up @@ -420,7 +425,7 @@ objects:
status:
ingress: null
- kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
metadata:
annotations: {}
creationTimestamp: null
Expand All @@ -439,4 +444,4 @@ objects:
name: cpu
target:
type: Utilization
averageUtilization: 80
averageUtilization: 80
58 changes: 11 additions & 47 deletions api/.pipeline/templates/queue.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ parameters:
- name: DB_SERVICE_NAME
description: 'Database service name associated with deployment'
required: true
# Node
- name: NODE_ENV
description: Application Environment type variable
required: true
value: 'dev'
# Elastic Search
- name: ELASTICSEARCH_URL
description: Platform Elasticsearch URL
required: true
Expand All @@ -41,43 +43,22 @@ parameters:
description: Platform Elasticsearch Taxonomy Index
required: true
vale: 'taxonomy_3.0.0'
- name: S3_KEY_PREFIX
description: S3 key optional prefix
required: false
value: 'biohub'
- name: TZ
description: Application timezone
required: false
value: 'America/Vancouver'
- name: KEYCLOAK_HOST
description: Key clock login url
required: true
- name: KEYCLOAK_REALM
description: Realm identifier or name
required: true
- name: KEYCLOAK_INTEGRATION_ID
description: keycloak integration id
required: true
- name: KEYCLOAK_API_HOST
description: keycloak API host
required: true
- name: KEYCLOAK_CLIENT_ID
description: Client Id for application
required: true
- name: KEYCLOAK_ADMIN_USERNAME
description: keycloak host admin username
required: true
- name: KEYCLOAK_SECRET
description: The name of the keycloak secret
required: true
- name: KEYCLOAK_SECRET_ADMIN_PASSWORD
description: The key of the admin password in the keycloak secret
required: true
# Object Store (S3)
- name: S3_KEY_PREFIX
description: S3 key optional prefix
required: false
value: 'biohub'
- name: OBJECT_STORE_SECRETS
description: Secrets used to read and write to the S3 storage
value: 'biohubbc-object-store'
# Log Level
- name: LOG_LEVEL
value: 'info'
# Openshift
- name: CPU_REQUEST
value: '100m'
- name: CPU_LIMIT
Expand Down Expand Up @@ -164,23 +145,6 @@ objects:
name: ${DB_SERVICE_NAME}
- name: DB_PORT
value: '5432'
- name: KEYCLOAK_HOST
value: ${KEYCLOAK_HOST}
- name: KEYCLOAK_API_HOST
value: ${KEYCLOAK_API_HOST}
- name: KEYCLOAK_REALM
value: ${KEYCLOAK_REALM}
- name: KEYCLOAK_CLIENT_ID
value: ${KEYCLOAK_CLIENT_ID}
- name: KEYCLOAK_INTEGRATION_ID
value: ${KEYCLOAK_INTEGRATION_ID}
- name: KEYCLOAK_ADMIN_USERNAME
value: ${KEYCLOAK_ADMIN_USERNAME}
- name: KEYCLOAK_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: ${KEYCLOAK_SECRET}
key: ${KEYCLOAK_SECRET_ADMIN_PASSWORD}
- name: CHANGE_VERSION
value: ${CHANGE_ID}
- name: NODE_ENV
Expand Down Expand Up @@ -273,7 +237,7 @@ objects:
name: ${NAME}${SUFFIX}
type: Opaque
- kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
metadata:
annotations: {}
creationTimestamp: null
Expand All @@ -292,4 +256,4 @@ objects:
name: cpu
target:
type: Utilization
averageUtilization: 80
averageUtilization: 80
103 changes: 103 additions & 0 deletions api/src/paths/administrative/submission/published.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import chai, { expect } from 'chai';
import { describe } from 'mocha';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import * as db from '../../../database/db';
import { HTTPError } from '../../../errors/http-error';
import { SECURITY_APPLIED_STATUS } from '../../../repositories/security-repository';
import { SubmissionRecordWithSecurityAndRootFeatureType } from '../../../repositories/submission-repository';
import { SubmissionService } from '../../../services/submission-service';
import { getMockDBConnection, getRequestHandlerMocks } from '../../../__mocks__/db';
import { getPublishedSubmissionsForAdmins } from './published';

chai.use(sinonChai);

describe('getPublishedSubmissionsForAdmins', () => {
afterEach(() => {
sinon.restore();
});

it('re-throws any error that is thrown', async () => {
const mockDBConnection = getMockDBConnection({
open: () => {
throw new Error('test error');
}
});

sinon.stub(db, 'getDBConnection').returns(mockDBConnection);

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

const requestHandler = getPublishedSubmissionsForAdmins();

try {
await requestHandler(mockReq, mockRes, mockNext);
expect.fail();
} catch (actualError) {
expect((actualError as HTTPError).message).to.equal('test error');
}
});

it('should return an array of Reviewed submission objects', async () => {
const dbConnectionObj = getMockDBConnection({
commit: sinon.stub(),
rollback: sinon.stub(),
release: sinon.stub()
});

sinon.stub(db, 'getDBConnection').returns(dbConnectionObj);

const mockResponse: SubmissionRecordWithSecurityAndRootFeatureType[] = [
{
submission_id: 1,
uuid: '123-456-789',
security_review_timestamp: '2023-12-12',
submitted_timestamp: '2023-12-12',
publish_timestamp: '2023-12-12',
source_system: 'SIMS',
name: 'name',
description: 'description',
create_date: '2023-12-12',
create_user: 1,
update_date: null,
update_user: null,
revision_count: 0,
security: SECURITY_APPLIED_STATUS.SECURED,
root_feature_type_id: 1,
root_feature_type_name: 'dataset'
},
{
submission_id: 2,
uuid: '789-456-123',
security_review_timestamp: '2023-12-12',
submitted_timestamp: '2023-12-12',
source_system: 'SIMS',
publish_timestamp: '2023-12-12',
name: 'name',
description: 'description',
create_date: '2023-12-12',
create_user: 1,
update_date: '2023-12-12',
update_user: 1,
revision_count: 1,
security: SECURITY_APPLIED_STATUS.PARTIALLY_SECURED,
root_feature_type_id: 1,
root_feature_type_name: 'dataset'
}
];

const { mockReq, mockRes, mockNext } = getRequestHandlerMocks();

const getReviewedSubmissionsStub = sinon
.stub(SubmissionService.prototype, 'getPublishedSubmissionsForAdmins')
.resolves(mockResponse);

const requestHandler = getPublishedSubmissionsForAdmins();

await requestHandler(mockReq, mockRes, mockNext);

expect(getReviewedSubmissionsStub).to.have.been.calledOnce;
expect(mockRes.statusValue).to.equal(200);
expect(mockRes.jsonValue).to.eql(mockResponse);
});
});
Loading

0 comments on commit 7f8b721

Please sign in to comment.