-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from aahna-ashina/dw-58/send-template-updates-to
Send template updates to Apple Wallet passes (#6)
- Loading branch information
Showing
38 changed files
with
1,686 additions
and
1,241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build and Lint | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: server | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x, 18.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
cache-dependency-path: server/package-lock.json | ||
- run: npm install | ||
|
||
- run: npm run build | ||
- run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Integration Tests | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: server | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x, 18.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
cache-dependency-path: server/package-lock.json | ||
- run: npm install | ||
|
||
- run: cp .env.local.goerli .env.local | ||
- run: npm run e2e:headless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Template Update | ||
|
||
This document explains, step-by-step, how to update the template of a pass. | ||
|
||
## Apple Templates | ||
|
||
1. Copy the the current template version to a new folder, e.g. `cp -r template-versions/apple/2 template-versions/apple/3` | ||
1. Commit the changes | ||
1. Make your changes in the new folder | ||
1. Commit the changes | ||
1. Increase the `appleTemplateVersion` in `utils/Config.ts` | ||
1. Test that the new pass is successfully generated by making a `[GET]` request to `http://localhost:3000/api/downloadPass` (see full request example in `cypress/e2e/api/apple/downloadPass.cy.ts`) | ||
1. Test that it works to open the generated `.pkpass` file on an iOS device | ||
1. Commit the changes | ||
|
||
## Google Templates | ||
|
||
`// TO DO` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
describe('Get the List of Updatable Passes', () => { | ||
|
||
it('error when wrong request method (POST instead of GET)', () => { | ||
cy.request({ | ||
method: 'POST', | ||
url: '/api/apple/v1/devices/b33e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3', | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(400) | ||
expect(JSON.stringify(response.body)).to.contain('Request Not Authorized: Wrong request method') | ||
}) | ||
}) | ||
|
||
it('204 when unknown deviceLibraryIdentifier', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/apple/v1/devices/cypress_b00e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3', | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(204) | ||
}) | ||
}) | ||
|
||
it('200 when existing deviceLibraryIdentifier', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/apple/v1/devices/cypress_b33e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3', | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(200) | ||
expect(JSON.stringify(response.body)).to.contain('serialNumbers') | ||
// TODO: verify serial number value(s) | ||
expect(JSON.stringify(response.body)).to.contain('lastUpdated') | ||
}) | ||
}) | ||
|
||
it('200 when existing deviceLibraryIdentifier and passesUpdatedSince=1662541136', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/apple/v1/devices/cypress_b33e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3?passesUpdatedSince=1662541136', | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(200) | ||
expect(JSON.stringify(response.body)).to.contain('serialNumbers') | ||
// TODO: verify serial number value(s) | ||
expect(JSON.stringify(response.body)).to.contain('lastUpdated') | ||
}) | ||
}) | ||
}) | ||
|
||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
describe('Log a Message', () => { | ||
|
||
it('error when wrong request method (GET instead of POST)', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/apple/v1/log', | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(401) | ||
expect(JSON.stringify(response.body)).to.contain('Request Not Authorized: Wrong request method') | ||
}) | ||
}) | ||
|
||
it('success when POST request', () => { | ||
cy.request({ | ||
method: 'POST', | ||
url: '/api/apple/v1/log', | ||
body: { | ||
logs: [ | ||
'[2022-09-06 09:14:07 +0800] Get serial #s task (for device b33e3a3dccb3030333e3333da33333a3, pass type pass.org.passport.nation3, last updated (null); with web service url https://passports.nation3.org/api/apple) encountered error: Unexpected response code 404', | ||
'[2022-09-06 09:14:07 +0800] Get serial #s task (for device b33e3a3dccb3030333e3333da33333a3, pass type pass.org.passport.nation3, last updated (null); with web service url https://passports.nation3.org/api/apple) encountered error: Unexpected response code 404' | ||
] | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(200) | ||
expect(JSON.stringify(response.body)).to.contain('OK') | ||
}) | ||
}) | ||
}) | ||
|
||
export {} |
61 changes: 61 additions & 0 deletions
61
server/cypress/e2e/api/apple/v1/passes/[passTypeIdentifier]/[serialNumber].cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import crypto from 'crypto' | ||
|
||
describe('Send an Updated Pass', () => { | ||
|
||
it('error when wrong request method (POST instead of GET)', () => { | ||
cy.request({ | ||
method: 'POST', | ||
url: '/api/apple/v1/passes/pass.org.passport.nation3/5', | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(401) | ||
expect(JSON.stringify(response.body)).to.contain('Request Not Authorized: Wrong request method') | ||
}) | ||
}) | ||
|
||
it('error when authentication token missing in header', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/apple/v1/passes/pass.org.passport.nation3/5', | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(401) | ||
expect(JSON.stringify(response.body)).to.contain('Request Not Authorized: Missing/empty header: Authorization') | ||
}) | ||
}) | ||
|
||
/** | ||
* A passport with ID 5 is expected to have been downloaded previously (see downloadPass.cy.ts). | ||
*/ | ||
it('success when valid authentication token in header', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/apple/v1/passes/pass.org.passport.nation3/5', | ||
headers: { | ||
'Authorization': 'ApplePass 0x3fbeb3ae33af3fb33f3d33333303d333a333aff33f3133efbc3330333adb333a' | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(200) | ||
expect(response.headers).to.include({ | ||
'content-type': 'application/vnd.apple.pkpass' | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
it('error when serial number missing from `downloads` table', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/apple/v1/passes/pass.org.passport.nation3/55555', | ||
headers: { | ||
'Authorization': 'ApplePass 0x3fbeb3ae33af3fb33f3d33333303d333a333aff33f3133efbc3330333adb333a' | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(500) | ||
expect(JSON.stringify(response.body)).to.contain('multiple (or no) rows returned') | ||
}) | ||
}) | ||
|
||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
create type platform as enum ('Apple', 'Google'); | ||
create table downloads ( | ||
id bigint generated by default as identity primary key, | ||
time_of_download timestamp without time zone default now() not null, | ||
platform platform not null, | ||
template_version int not null, | ||
passport_id bigint not null, | ||
issue_date timestamp without time zone not null, | ||
address text not null, | ||
ens_name text | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
delete from registrations; | ||
alter table registrations add column template_version int not null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
create table latest_updates ( | ||
id bigint generated by default as identity primary key, | ||
time timestamp without time zone default now() not null, | ||
title text not null, | ||
content text not null | ||
); | ||
insert into latest_updates (title, content) values ('N3GOV-16: All governance proposals must explain how they help advance the North Star metrics', 'This is very self-descriptive, but it''s a nice add-on to Proposal: Set Nation3''s North Star metrics. We have seen too many times how DAOs end up with endless bureaucracy because there''s no room for execution amidst chaos and uncertainty. Therefore having a unified set of metrics to advance, and making all governance proposals adhere to advancing them, makes sense. This is the pull request to the governance proposals repo, and this is the specific change.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,5 @@ export interface GooglePass extends Pass { | |
|
||
export enum Platform { | ||
Apple, | ||
Google, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ module.exports = { | |
testEnvironment: 'node', | ||
coverageThreshold: { | ||
global: { | ||
lines: 18.55 | ||
lines: 80.00 | ||
} | ||
} | ||
} |
Oops, something went wrong.
b5aedc3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mobile-passport – ./
passports.nation3.org
mobile-passport-nation3.vercel.app
mobile-passport-git-main-nation3.vercel.app
mobile-passport.vercel.app