Skip to content

Commit

Permalink
Release 3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-robitaille authored May 3, 2023
2 parents 8d59286 + 76c8d8b commit e9358eb
Show file tree
Hide file tree
Showing 81 changed files with 2,316 additions and 1,085 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG VARIANT=16@sha256:dc3280bb4ad533d74af105dff9eefd95619adf54d1f1bfc753e060b7c47e9b9d@sha256:b35e76ba744a975b9a5428b6c3cde1a1cf0be53b246e1e9a4874f87034222b5a@sha256:b35e76ba744a975b9a5428b6c3cde1a1cf0be53b246e1e9a4874f87034222b5a
ARG VARIANT=16@sha256:c94897fb8f81904dff61bc9e2f25eb66124c3b802afeb3f3ee48f82a3986fe64@sha256:b35e76ba744a975b9a5428b6c3cde1a1cf0be53b246e1e9a4874f87034222b5a@sha256:b35e76ba744a975b9a5428b6c3cde1a1cf0be53b246e1e9a4874f87034222b5a

FROM node:${VARIANT}

Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:

redis:
restart: unless-stopped
image: redis:latest@sha256:f50031a49f41e493087fb95f96fdb3523bb25dcf6a3f0b07c588ad3cdbe1d0aa
image: redis:latest@sha256:93a5ed8cdfa909a12cb41e5605c147756b804a9fe38376f8afed133f427ea828
ports:
- "6379:6379"
expose:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@7df0ce34898d659f95c0c4a09eaa8d4e32ee64db # v2.2.12
uses: github/codeql-action/init@b2c19fb9a2a485599ccf4ed5d65527d94bc57226 # v2.3.0
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -42,7 +42,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@7df0ce34898d659f95c0c4a09eaa8d4e32ee64db # v2.2.12
uses: github/codeql-action/autobuild@b2c19fb9a2a485599ccf4ed5d65527d94bc57226 # v2.3.0

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -56,4 +56,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@7df0ce34898d659f95c0c4a09eaa8d4e32ee64db # v2.2.12
uses: github/codeql-action/analyze@b2c19fb9a2a485599ccf4ed5d65527d94bc57226 # v2.3.0
17 changes: 12 additions & 5 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,21 @@ jobs:
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 16
cache: "yarn"
cache-dependency-path: |
yarn.lock
flag_initialization/yarn.lock
migrations/yarn.lock
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: "Install dependencies"
run: yarn install:all

- name: Cypress Tests
uses: cypress-io/github-action@d79d2d530a66e641eb4a5f227e13bc985c60b964 # v4.2.2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-vulnerability-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
steps:
- name: Configure Staging AWS credentials
id: aws-form-viewer
uses: aws-actions/configure-aws-credentials@31bd3ae2db62cebd1f7f32dfb55b31145fee0b40
uses: aws-actions/configure-aws-credentials@82ea2d2853906c3fe78152101e590fa6caeb5f82
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ca-central-1

- name: Login to Staging Amazon ECR
id: login-ecr-staging
uses: aws-actions/amazon-ecr-login@68a8d266c7934a50d8dc78f37da40be57a98117a
uses: aws-actions/amazon-ecr-login@a1d6e39e3457a150e0fff2455c74032ceeff69a6

- name: Docker vulnerability scan
uses: cds-snc/security-tools/.github/actions/docker-scan@cfec0943e40dbb78cee115bbbe89dc17f07b7a0f # v2.1.3
Expand Down
45 changes: 31 additions & 14 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@ jobs:
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 16
cache: "yarn"
cache-dependency-path: |
yarn.lock
flag_initialization/yarn.lock
migrations/yarn.lock
- name: Install Node Dependencies
run: yarn install

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: "Install dependencies"
run: yarn install:all

env:
CI: TRUE
- name: Test Code Linting on Merge
Expand All @@ -37,13 +46,21 @@ jobs:
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 16
cache: "yarn"
cache-dependency-path: |
yarn.lock
flag_initialization/yarn.lock
migrations/yarn.lock
- name: Install Node Dependencies
run: yarn install:all

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: "Install dependencies"
run: yarn install:all --prefer-offline
env:
CI: TRUE
- name: Test Code Linting on Pull Request
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ jobs:
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 16
cache: "yarn"
cache-dependency-path: |
yarn.lock
flag_initialization/yarn.lock
migrations/yarn.lock

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: "Install dependencies"
run: yarn install
run: yarn install:all

- name: Jest Tests
run: yarn test --coverage
4 changes: 2 additions & 2 deletions .github/workflows/prod-build-push-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ jobs:
- name: Configure Production AWS credentials
id: aws-form-viewer
uses: aws-actions/configure-aws-credentials@31bd3ae2db62cebd1f7f32dfb55b31145fee0b40
uses: aws-actions/configure-aws-credentials@82ea2d2853906c3fe78152101e590fa6caeb5f82
with:
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}
aws-region: ca-central-1

- name: Login to Production Amazon ECR
id: login-ecr-production
uses: aws-actions/amazon-ecr-login@68a8d266c7934a50d8dc78f37da40be57a98117a
uses: aws-actions/amazon-ecr-login@a1d6e39e3457a150e0fff2455c74032ceeff69a6

- name: Tag Images for Production
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/staging-build-push-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ jobs:
- name: Configure Staging AWS credentials
id: aws-form-viewer
uses: aws-actions/configure-aws-credentials@31bd3ae2db62cebd1f7f32dfb55b31145fee0b40
uses: aws-actions/configure-aws-credentials@82ea2d2853906c3fe78152101e590fa6caeb5f82
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ca-central-1

- name: Login to Staging Amazon ECR
id: login-ecr-staging
uses: aws-actions/amazon-ecr-login@68a8d266c7934a50d8dc78f37da40be57a98117a
uses: aws-actions/amazon-ecr-login@a1d6e39e3457a150e0fff2455c74032ceeff69a6

- name: Tag Images for Staging
env:
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Configure AWS credentials
# v1 as of Jan 28 2021
uses: aws-actions/configure-aws-credentials@31bd3ae2db62cebd1f7f32dfb55b31145fee0b40
uses: aws-actions/configure-aws-credentials@82ea2d2853906c3fe78152101e590fa6caeb5f82
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Login to Amazon ECR
id: login-ecr
# v1 as of Jan 28 2021
uses: aws-actions/amazon-ecr-login@68a8d266c7934a50d8dc78f37da40be57a98117a
uses: aws-actions/amazon-ecr-login@a1d6e39e3457a150e0fff2455c74032ceeff69a6

- name: Get Cluster Name
id: cluster
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Render image for form viewer service
id: taskdef-form-viewer
# v1.0.10
uses: aws-actions/amazon-ecs-render-task-definition@efa47210a371c3e0f50c913d47a482ad71344d86
uses: aws-actions/amazon-ecs-render-task-definition@b451ae8d4af191e94b479ca69435c85a0bd25140
with:
task-definition: form_viewer.json
container-name: ${{ steps.download-taskdef-form-viewer.outputs.container_name }}
Expand All @@ -67,20 +67,14 @@ jobs:
- name: Deploy image for Form Viewer
timeout-minutes: 10
# v1.4.11
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
uses: aws-actions/amazon-ecs-deploy-task-definition@290c43e7b1deae23e799b76e42b5cfcbc2f8f4cb
with:
task-definition: ${{ steps.taskdef-form-viewer.outputs.task-definition }}
service: form-viewer
cluster: ${{ steps.cluster.outputs.name }}
wait-for-service-stability: true
codedeploy-appspec: ${{ github.workspace }}/form-viewer-appspec.json

- name: Run scan websites
run: |
curl -s https://scan-websites.alpha.canada.ca > /dev/null
sleep 60
curl -X GET -H 'X-API-KEY: ${{ secrets.SCAN_WEBSITES_KEY }}' -H 'X-TEMPLATE-TOKEN: ${{ secrets.SCAN_WEBSITES_TEMPLATE }}' https://scan-websites.alpha.canada.ca/scans/start
- name: Logout of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}
15 changes: 0 additions & 15 deletions .github/workflows/weekly-dynamic-security-scan.yml

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.3] 2023-05-03

### Fixed

- Responses page is not available if form does not exist (deleted). [2023](https://github.com/cds-snc/platform-forms-client/issues/2023)
- Content Changes
- Expanding title element in form builder

## [3.0.2] 2023-04-28

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16@sha256:241f152c0dc9d3efcbd6a4426f52dc50fa78f3a63cff55b2419dc2bf48efe705
FROM node:16@sha256:e64998c9e7912aa74647c1d8779cea6dc7ff017327265fb6855522270eab80e4

ENV NODE_ENV=production

Expand All @@ -15,19 +15,19 @@ RUN yarn install --silent --production=false
RUN yarn build
RUN yarn install --production

FROM node:16@sha256:241f152c0dc9d3efcbd6a4426f52dc50fa78f3a63cff55b2419dc2bf48efe705
FROM node:16@sha256:e64998c9e7912aa74647c1d8779cea6dc7ff017327265fb6855522270eab80e4

COPY migrations /src
WORKDIR /src
RUN yarn install --silent

FROM node:16@sha256:241f152c0dc9d3efcbd6a4426f52dc50fa78f3a63cff55b2419dc2bf48efe705
FROM node:16@sha256:e64998c9e7912aa74647c1d8779cea6dc7ff017327265fb6855522270eab80e4

COPY flag_initialization /src
WORKDIR /src
RUN yarn install --silent

FROM node:16@sha256:241f152c0dc9d3efcbd6a4426f52dc50fa78f3a63cff55b2419dc2bf48efe705
FROM node:16@sha256:e64998c9e7912aa74647c1d8779cea6dc7ff017327265fb6855522270eab80e4
LABEL maintainer="-"

ARG GOOGLE_CLIENT_ID
Expand Down
3 changes: 1 addition & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
3.0.2

3.0.3
43 changes: 42 additions & 1 deletion __tests__/api/templates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import brokenFormTemplate from "../../__fixtures__/brokenFormTemplate.json";
import { prismaMock } from "@jestUtils";
import { Session } from "next-auth";
import { Base, mockUserPrivileges, ManageForms, PublishForms } from "__utils__/permissions";
import { numberOfUnprocessedSubmissions } from "@lib/vault";

//Needed in the typescript version of the test so types are inferred correctly
const mockGetSession = jest.mocked(getServerSession, { shallow: true });
Expand All @@ -26,6 +27,12 @@ jest.mock("@lib/integration/redisConnector", () => ({
getRedisInstance: jest.fn(() => redis),
}));

jest.mock("@lib/vault");

const mockNumberOfUnprocessedSubmissions = jest.mocked(numberOfUnprocessedSubmissions, {
shallow: true,
});

describe("Requires a valid session to access API", () => {
it("Should successfully handle a POST request to create a template", async () => {
const { req, res } = createMocks({
Expand Down Expand Up @@ -215,7 +222,7 @@ describe("Test templates API functions", () => {

await templates(req, res);

expect(res.statusCode).toBe(500);
expect(res.statusCode).toBe(409);
expect(JSON.parse(res._getData())).toEqual(
expect.objectContaining({ error: "Can't update published form" })
);
Expand Down Expand Up @@ -356,6 +363,40 @@ describe("Test templates API functions", () => {

expect(res.statusCode).toBe(200);
});

it("Should return specific error message when trying to delete form that has unprocessed submissions", async () => {
(prismaMock.template.findUnique as jest.MockedFunction<any>).mockResolvedValue({
id: "formtestID",
jsonConfig: validFormTemplate,
users: [{ id: "1" }],
});

(prismaMock.template.update as jest.MockedFunction<any>).mockResolvedValue({
id: "test0form00000id000asdf11",
jsonConfig: validFormTemplate,
});

mockNumberOfUnprocessedSubmissions.mockResolvedValueOnce(1);

const { req, res } = createMocks({
method: "DELETE",
url: "/api/templates/test0form00000id000asdf11",
query: {
formID: "test0form00000id000asdf11",
},
headers: {
"Content-Type": "application/json",
Origin: "http://localhost:3000",
},
});

await templates(req, res);

expect(res.statusCode).toBe(405);
expect(JSON.parse(res._getData())).toEqual(
expect.objectContaining({ error: "Found unprocessed submissions" })
);
});
});
});

Expand Down
Loading

0 comments on commit e9358eb

Please sign in to comment.