-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send template updates to Apple Wallet passes (#6) #73
Changes from 28 commits
5762a0b
e61226c
9949666
9b71e6e
80a62c0
7a28c59
6fab905
aaa4090
9683cee
f7d5e47
d6eadcb
0b79dae
9f853c7
61cf805
6e14a36
a05caf7
4a7b8b8
ec05a78
ef9a065
e2854f4
7746528
5af5e57
9dd6b5f
659d80c
90afce2
beb8718
97bcfa3
3feadd1
7e423d9
a8f6f52
cbfb085
7e0beaf
4991d07
832c734
21032c2
ed3c128
42ef3cf
f722672
848304e
0943c3d
50c28f3
43ec3c4
2e04076
6799a63
1032a01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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') | ||
expect(JSON.stringify(response.body)).to.contain('lastUpdated') | ||
// TODO: verify serial number value(s) | ||
}) | ||
}) | ||
}) | ||
|
||
export {} |
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 {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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/333', | ||
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/333', | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(401) | ||
expect(JSON.stringify(response.body)).to.contain('Request Not Authorized: Missing/empty header: Authorization') | ||
}) | ||
}) | ||
|
||
it('success when valid authentication token in header', () => { | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/apple/v1/passes/pass.org.passport.nation3/333', | ||
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' | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
export {} |
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 | ||
); |
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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,5 @@ export interface GooglePass extends Pass { | |
|
||
export enum Platform { | ||
Apple, | ||
Google, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a Prettier change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @johnmark13 No, haven't added Prettier config yet. Maybe we should? Added it to #76 |
||
} |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💪 |
||
} | ||
} | ||
} |
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.
I'd probably rename these files as
.local
is not usually checked into a repository, not a big deal though.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.
@johnmark13 The Goerli environment variables are needed for running unit tests and integration tests.