Skip to content

Commit

Permalink
Merge pull request #113 from flexion/master
Browse files Browse the repository at this point in the history
Sprint 27
  • Loading branch information
JessicaMarine authored Nov 26, 2019
2 parents b91025a + 9eb7477 commit c071eb2
Show file tree
Hide file tree
Showing 617 changed files with 18,327 additions and 6,425 deletions.
25 changes: 18 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ jobs:
- run:
name: Pa11y
command: |
SLS_DEBUG=* AWS_ACCESS_KEY_ID=noop AWS_SECRET_ACCESS_KEY=noop npx run-p start:api:ci start:client:ci > /dev/null &
npm run build:all &&
SLS_DEBUG=* RUN_DIR=dist AWS_ACCESS_KEY_ID=noop AWS_SECRET_ACCESS_KEY=noop npx run-p start:api:ci start:client:ci > /dev/null &
./wait-until-services.sh
./wait-until.sh http://localhost:3000/api/swagger
sleep 5
Expand All @@ -147,12 +148,13 @@ jobs:
- run:
name: Cypress
command: |
npm run build:all &&
CYPRESS_VERSION=`./node_modules/.bin/cypress --version | awk -F' ' '{print $4; exit}'`
if [ ! -e "/root/.cache/Cypress/${CYPRESS_VERSION}/Cypress/Cypress" ]; then
./node_modules/.bin/cypress install
fi
SLS_DEBUG=* AWS_ACCESS_KEY_ID=noop AWS_SECRET_ACCESS_KEY=noop npx run-p start:api:ci start:client:ci > /dev/null &
SLS_DEBUG=* RUN_DIR=dist AWS_ACCESS_KEY_ID=noop AWS_SECRET_ACCESS_KEY=noop npx run-p start:api:ci start:client:ci > /dev/null &
./wait-until-services.sh
./wait-until.sh http://localhost:3000/api/swagger
sleep 5
Expand All @@ -171,15 +173,18 @@ jobs:
- run:
name: Setup Env
command: echo "export ENV=$(./get-env.sh $CIRCLE_BRANCH)" >> $BASH_ENV
- run:
name: Setup Post Confirmation Arn
command: echo "export POST_CONFIRMATION_ROLE_ARN=$(./get-post-confirmation-role-arn.sh $CIRCLE_BRANCH)" >> $BASH_ENV
- run:
name: Setup Dynamsoft Keys
command: echo "export DYNAMSOFT_PRODUCT_KEYS='$(./get-keys.sh $CIRCLE_BRANCH)'" >> $BASH_ENV
- run:
name: 'Deploy - Web Client - Terraform'
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "DYNAMSOFT_S3_ZIP_PATH=${DYNAMSOFT_S3_ZIP_PATH}" -e "DYNAMSOFT_URL=${DYNAMSOFT_URL}" -e "DYNAMSOFT_PRODUCT_KEYS=${DYNAMSOFT_PRODUCT_KEYS}" --rm efcms /bin/sh -c "cd web-client/terraform/main && ../bin/deploy-app.sh $ENV"
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "DYNAMSOFT_S3_ZIP_PATH=${DYNAMSOFT_S3_ZIP_PATH}" -e "DYNAMSOFT_URL=${DYNAMSOFT_URL}" -e "DYNAMSOFT_PRODUCT_KEYS=${DYNAMSOFT_PRODUCT_KEYS}" -e "IS_DYNAMSOFT_ENABLED=${IS_DYNAMSOFT_ENABLED}" --rm efcms /bin/sh -c "cd web-client/terraform/main && ../bin/deploy-app.sh $ENV"
- run:
name: 'Deploy - Web API - Terraform'
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "COGNITO_SUFFIX=${COGNITO_SUFFIX}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "SES_DMARC_EMAIL=${SES_DMARC_EMAIL}" --rm efcms /bin/sh -c "cd web-api/terraform/main && ../bin/deploy-app.sh ${ENV}"
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "COGNITO_SUFFIX=${COGNITO_SUFFIX}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" -e "SES_DMARC_EMAIL=${SES_DMARC_EMAIL}" -e "POST_CONFIRMATION_ROLE_ARN=${POST_CONFIRMATION_ROLE_ARN}" -e "CLOUDWATCH_ROLE_ARN=${CLOUDWATCH_ROLE_ARN}" --rm efcms /bin/sh -c "cd web-api/terraform/main && ../bin/deploy-app.sh ${ENV}"
- run:
name: Setup Elasticsearch Index Settings
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "EFCMS_DOMAIN=${EFCMS_DOMAIN}" --rm efcms /bin/sh -c "./web-api/setup-elasticsearch-index.sh ${ENV}"
Expand Down Expand Up @@ -321,12 +326,18 @@ jobs:
- run:
name: 'Deploy - Web API - Cognito Create Users'
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "USTC_ADMIN_PASS=${USTC_ADMIN_PASS}" --rm efcms /bin/sh -c "cd web-api && ./setup-cognito-users.sh ${ENV}"
- run:
name: 'Deploy - Web API - Run Migrations'
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" --rm efcms /bin/sh -c "./web-api/run-umzug.sh ${ENV}"
- run:
name: 'Deploy - Web API - Smoke Tests - us-east-1'
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" --rm efcms /bin/sh -c "cd web-api && ./run-smoketests.sh ${ENV} us-east-1"
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" --rm efcms /bin/sh -c "cd web-api && node smoke-tests.js ${ENV} us-east-1"
- run:
name: 'Deploy - Web API - Smoke Tests - us-west-1'
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" --rm efcms /bin/sh -c "cd web-api && ./run-smoketests.sh ${ENV} us-west-1"
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" --rm efcms /bin/sh -c "cd web-api && node smoke-tests.js ${ENV} us-west-1"
- run:
name: 'Deploy - Cypress Smoke Tests'
command: docker run -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" --rm efcms /bin/sh -c "CYPRESS_BASE_URL='https://ui-$ENV.$EFCMS_DOMAIN' ENV=${ENV} npm run cypress:smoketests"

workflows:
version: 2
Expand All @@ -342,7 +353,7 @@ workflows:
- deploy-api-east
triggers:
- schedule:
cron: '0,30 12-23 * * 1-5'
cron: '0 12-23 * * 1-5'
filters:
branches:
only:
Expand Down
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ module.exports = {
'jsdoc/require-returns': 1,
'jsdoc/valid-types': 1,
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'no-warning-comments': [
'error',
{ terms: ['fixme', 'xxx'], location: 'anywhere' },
],
'prettier/prettier': 'error',
quotes: ['error', 'single', { avoidEscape: true }],
'jsx-a11y/anchor-is-valid': [
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ aws.json
coverage/
cypress/screenshots
cypress/videos
cypress-smoketests/screenshots
cypress-smoketests/videos
dist/
gen.conf
graph-generators/node_modules/
graph-generators/*png
node_modules/
parcel-debug-*
**/*_.js
/policy.json
puppeteer_lambda_layer.tar.gz
shared/coverage
Expand All @@ -29,4 +32,6 @@ web-client/reports
web-client/tests_output/
web-client/coverage-e2e
web-client/pa11y/pa11y-screenshots
web-api/terraform/template/cognito-triggers/index.js.zip
web-api/terraform/template/cognito-triggers/index.js.zip
lambda-policy.json
.vscode
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
package.json
*.md
*_.js
17 changes: 17 additions & 0 deletions cypress-smoketests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"baseUrl": "https://ui-dev.ustc-case-mgmt.flexion.us",
"reporter": "spec",
"reporterOptions": {
"toConsole": true
},
"fixturesFolder": "cypress-smoketests/fixtures",
"integrationFolder": "cypress-smoketests/integration",
"pluginsFile": "cypress-smoketests/plugins/index.js",
"screenshotsFolder": "cypress-smoketests/screenshots",
"videosFolder": "cypress-smoketests/videos",
"supportFile": "cypress-smoketests/support/index.js",
"defaultCommandTimeout": 12000,
"requestTimeout": 12000,
"viewportWidth": 1200,
"viewportHeight": 900
}
77 changes: 77 additions & 0 deletions cypress-smoketests/integration/petitionsclerk-can-login.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const AWS = require('aws-sdk');

AWS.config = new AWS.Config();
AWS.config.accessKeyId = Cypress.env('AWS_ACCESS_KEY_ID');
AWS.config.secretAccessKey = Cypress.env('AWS_SECRET_ACCESS_KEY');
AWS.config.region = 'us-east-1';

const ENV = Cypress.env('ENV');

const cognito = new AWS.CognitoIdentityServiceProvider({
region: 'us-east-1',
});

const getClientId = async userPoolId => {
const results = await cognito
.listUserPoolClients({
MaxResults: 60,
UserPoolId: userPoolId,
})
.promise();
const clientId = results.UserPoolClients[0].ClientId;
return clientId;
};

const getUserPoolId = async () => {
const results = await cognito
.listUserPools({
MaxResults: 50,
})
.promise();
const userPoolId = results.UserPools.find(
pool => pool.Name === `efcms-${ENV}`,
).Id;
return userPoolId;
};

const getUserToken = async (username, password) => {
const userPoolId = await getUserPoolId();
const clientId = await getClientId(userPoolId);

return cognito
.adminInitiateAuth({
AuthFlow: 'ADMIN_NO_SRP_AUTH',
AuthParameters: {
PASSWORD: password,
USERNAME: username,
},
ClientId: clientId,
UserPoolId: userPoolId,
})
.promise();
};

let token = null;

describe('petitionsclerk can login', () => {
before(async () => {
const results = await getUserToken(
'petitionsclerk1@example.com',
'Testing1234$',
);
token = results.AuthenticationResult.IdToken;
});

it('views the section inbox', async () => {
cy.visit(`/log-in?token=${token}`);
cy.get('.button-switch-box').should('exist');
});

it('should verify advanced search works', () => {
cy.visit(`/log-in?token=${token}&path=/search`);
cy.get('#advanced-search-button').should('exist');
cy.get('#petitioner-name').type('THISNAMESHOULDNEVEREXIST');
cy.get('#advanced-search-button').click();
cy.get('#no-search-results').should('exist');
});
});
17 changes: 17 additions & 0 deletions cypress-smoketests/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};
28 changes: 28 additions & 0 deletions cypress-smoketests/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { previousSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { previousSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

// https://github.com/cypress-io/cypress/issues/170
// Usage: cy.upload_file('building.jpg', '#building [type="file"]');
20 changes: 20 additions & 0 deletions cypress-smoketests/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')
1 change: 0 additions & 1 deletion cypress/integration/assign-a-work-item-to-self.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const {
getSectionUsersSelect,
getWorkItemCheckboxLabel,
getWorkItemMessage,
getWorkItemMessages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
describe('Edit a case caption from case detail header', function() {
before(() => {
cy.seed();
navigateToCaseDetail('petitionsclerk', '101-19');
navigateToCaseDetail('docketclerk', '101-19');
getEditCaseCaptionButton().click();
getCaptionTextArea()
.clear()
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/pages/case-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exports.navigateTo = (username, caseId) => {
};

exports.getEditCaseCaptionButton = () => {
return cy.get('button#caption-edit-button');
return cy.get('button#edit-case-context-button');
};

exports.getCaptionTextArea = () => {
Expand Down
3 changes: 1 addition & 2 deletions docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ docker run -t -i \
-e AWS_SECRET_ACCESS_KEY=noop \
-p 1234:1234 \
-p 3000:3000 \
-p 3011:3011 \
-p 8000:8000 \
-p 8001:8001 \
-p 9000:9000 \
--rm efcms /bin/sh \
-c "(npm run start:api &) && (npm run dynamo:admin &) && (npm run print:success &) && npm run start:client"
-c "(npm run start:api &) && (npm run dynamo:admin &) && (./wait-until-services.sh && sleep 10 && npm run print:success &) && npm run start:client"
15 changes: 11 additions & 4 deletions docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
## Prerequisites
- [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/).
- Create a `CircleCI` user in [AWS Identity and Access Management](https://console.aws.amazon.com/iam/):
- Determine your organization’s AWS ID, a 12-digit number. While logged into the AWS Console, you can find this in the account menu in the top right, where it may appear with hyphens, e.g. `3503-6506-1526`.
- In your local copy of the repository, generate an IAM policy with `./generate-policy.sh [YOUR_ACCOUNT_ID]`, e.g. `generate-policy.sh 350365061526`.
- Create a IAM policy called `CircleCIPolicy`, populating it with the contents of the generated `policy.json`.
- Create the `CircleCI` user and attach the policy.
- Create the `circle_ci_policy` via the project terraform scripts
`cd iam/account-specific/terraform/main && ../bin/deploy-app.sh`
- Attach this policy to your `CircleCI` user.
- Keep track of the access key and secret access key — it is needed for the CircleCI setup.
- [Create a Route53 Hosted Zone](https://console.aws.amazon.com/route53/home) This will be used for setting up the domains for the UI and API. Put the desired domain name (e.g. `ef-cms.example.gov.`) and make sure it is a `Public Hosted Zone`. This is the value you will set for `EFCMS_DOMAIN` in CircleCI. Make sure the domain name ends with a period.
- Create the lambda roles & policies needed for the lambdas that run the backend:
- `cd iam/environment-specific/terraform/main && ../bin/deploy-app dev`
- `cd iam/environment-specific/terraform/main && ../bin/deploy-app stg`
- `cd iam/environment-specific/terraform/main && ../bin/deploy-app prod`
- [Create a SonarCloud account](https://sonarcloud.io/). SonarCloud will be used to tests each build.
- [Create a new SonarCloud organization](https://sonarcloud.io/create-organization).
- There are three sub-projects to the EF-CMS — the front-end (the UI), the back-end (the API), and shared code. Each is handled separately by Jenkins and SonarCloud.
Expand Down Expand Up @@ -45,5 +48,9 @@
- `DYNAMSOFT_PRODUCT_KEYS_STG` (the product key provided after purchasing dynamsoft)
- `DYNAMSOFT_PRODUCT_KEYS_PROD` (the product key provided after purchasing dynamsoft)
- `DYNAMSOFT_S3_ZIP_PATH` (the full s3 path to the dynamsoft .tar.zip, e.g. `s3://ef-cms.ustaxcourt.gov-software/Dynamsoft/dynamic-web-twain-sdk-14.3.1.tar.gz`)
- `CLOUDWATCH_ROLE_ARN` (the arn output after running terraform in the iam/account-specific/terraform/main dir)
- `POST_CONFIRMATION_ROLE_ARN_DEV` (the arn output after running terraform in the iam/environment-specific/terraform/main dir)
- `POST_CONFIRMATION_ROLE_ARN_STG` (the arn output after running terraform in the iam/environment-specific/terraform/main dir)
- `POST_CONFIRMATION_ROLE_ARN_PROD` (the arn output after running terraform in the iam/environment-specific/terraform/main dir)
- `SES_DMARC_EMAIL` (email address used with SES to which aggregate DMARC validations are sent)
8. Run a build.
Binary file modified docs/images/client-dependencies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/server-dependencies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c071eb2

Please sign in to comment.