diff --git a/server/cypress/e2e/api/apple/[passTypeIdentifier].cy.ts b/server/cypress/e2e/api/apple/[passTypeIdentifier].cy.ts index 9805fc9..2577fb5 100644 --- a/server/cypress/e2e/api/apple/[passTypeIdentifier].cy.ts +++ b/server/cypress/e2e/api/apple/[passTypeIdentifier].cy.ts @@ -11,21 +11,10 @@ describe('Get the List of Updatable Passes', () => { }) }) - it('error when missing passesUpdatedSince parameter', () => { - cy.request({ - method: 'GET', - 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('Missing/empty parameter: passesUpdatedSince') - }) - }) - it('204 when unknown deviceLibraryIdentifier', () => { cy.request({ method: 'GET', - url: '/api/apple/v1/devices/b00e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3?passesUpdatedSince={previousLastUpdated}', + url: '/api/apple/v1/devices/b00e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3', failOnStatusCode: false }).then((response) => { expect(response.status).to.eq(204) @@ -35,13 +24,13 @@ describe('Get the List of Updatable Passes', () => { it('200 when existing deviceLibraryIdentifier', () => { cy.request({ method: 'GET', - url: '/api/apple/v1/devices/b33e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3?passesUpdatedSince={previousLastUpdated}', + url: '/api/apple/v1/devices/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 values + // TODO: verify serial number value(s) }) }) }) diff --git a/server/cypress/e2e/api/apple/[serialNumber].cy.ts b/server/cypress/e2e/api/apple/[serialNumber].cy.ts index 2731151..3073b78 100644 --- a/server/cypress/e2e/api/apple/[serialNumber].cy.ts +++ b/server/cypress/e2e/api/apple/[serialNumber].cy.ts @@ -70,7 +70,7 @@ describe('Register a Pass for Update Notifications', () => { }) it('success when deviceLibraryIdentifier is not already registered', () => { - const randomDeviceLibraryIdentifier : string = crypto.randomBytes(32).toString('hex') + const randomDeviceLibraryIdentifier : string = 'cypress_' + crypto.randomBytes(16).toString('hex') cy.request({ method: 'POST', url: '/api/apple/v1/devices/' + randomDeviceLibraryIdentifier + '/registrations/pass.org.passport.nation3/333', diff --git a/server/pages/api/apple/v1/devices/[deviceLibraryIdentifier]/registrations/[passTypeIdentifier].ts b/server/pages/api/apple/v1/devices/[deviceLibraryIdentifier]/registrations/[passTypeIdentifier].ts index 0d6bf13..a7787b2 100644 --- a/server/pages/api/apple/v1/devices/[deviceLibraryIdentifier]/registrations/[passTypeIdentifier].ts +++ b/server/pages/api/apple/v1/devices/[deviceLibraryIdentifier]/registrations/[passTypeIdentifier].ts @@ -9,8 +9,8 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) { console.log('[passTypeIdentifier].ts') // Expected URL format: - // /api/apple/v1/devices/[deviceLibraryIdentifier]/registrations/[passTypeIdentifier]?passesUpdatedSince=[passesUpdatedSince] - // /api/apple/v1/devices/b33e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3?passesUpdatedSince=0 + // /api/apple/v1/devices/[deviceLibraryIdentifier]/registrations/[passTypeIdentifier] + // /api/apple/v1/devices/b33e3a3dccb3030333e3333da33333a3/registrations/pass.org.passport.nation3 console.log('req.url:', req.url) try { @@ -26,15 +26,11 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) { console.log('deviceLibraryIdentifier:', deviceLibraryIdentifier) console.log('passesUpdatedSince:', passesUpdatedSince) - // Validate the passesUpdatedSince parameter - if (!passesUpdatedSince || String(passesUpdatedSince).trim().length == 0) { - throw new Error('Missing/empty parameter: passesUpdatedSince') - } - // Lookup the serial numbers for the given device supabase .from('registrations') - .select('serial_number').eq('device_library_identifier', deviceLibraryIdentifier) + .select('serial_number') + .eq('device_library_identifier', deviceLibraryIdentifier) .then((result: any) => { console.log('result:', result) if (result.error) { @@ -57,7 +53,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) { // Return matching passes (serial numbers) res.status(200).json({ serialNumbers: serialNumbers, - lastUpdated: 0 // TODO + lastUpdated: 'TODO' }) } }