From 7624a895e0120d6acaa74eb64e76183a47fb5ec3 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Wed, 7 Nov 2018 12:35:07 +0100 Subject: [PATCH] Uniformed filenames for certificates, fixed some problems in tests (maybe related to legal/solar time?) --- examples/barcode.js | 6 +- examples/expiration.js | 8 +- examples/fields.js | 166 +++++++++++++++++++-------------------- examples/localization.js | 6 +- tests/index.js | 24 +++--- 5 files changed, 105 insertions(+), 105 deletions(-) diff --git a/examples/barcode.js b/examples/barcode.js index fa92acc..24ed126 100644 --- a/examples/barcode.js +++ b/examples/barcode.js @@ -19,9 +19,9 @@ app.all(function manageRequest(request, response) { model: `./models/${request.params.modelName}`, certificates: { wwdr: "../certificates/WWDR.pem", - signerCert: "../certificates/passcertificate.pem", + signerCert: "../certificates/signerCert.pem", signerKey: { - keyFile: "../certificates/passkey.pem", + keyFile: "../certificates/signerKey.pem", passphrase: "123456" } }, @@ -71,7 +71,7 @@ app.all(function manageRequest(request, response) { console.log("Barcode property is now:", pass._props["barcode"]); console.log("Barcodes support is autocompleted:", pass._props["barcodes"]); - pass.generate().then(function(stream) { + pass.generate().then(function (stream) { response.set({ "Content-type": "application/vnd.apple.pkpass", "Content-disposition": `attachment; filename=${passName}.pkpass` diff --git a/examples/expiration.js b/examples/expiration.js index b682c04..662a83a 100644 --- a/examples/expiration.js +++ b/examples/expiration.js @@ -22,9 +22,9 @@ app.all(function manageRequest(request, response) { model: `./models/${request.params.modelName}`, certificates: { wwdr: "../certificates/WWDR.pem", - signerCert: "../certificates/passcertificate.pem", + signerCert: "../certificates/signerCert.pem", signerKey: { - keyFile: "../certificates/passkey.pem", + keyFile: "../certificates/signerKey.pem", passphrase: "123456" } }, @@ -36,13 +36,13 @@ app.all(function manageRequest(request, response) { } else if (request.query.fn === "expiration") { // 2 minutes later... let d = new Date(); - d.setMinutes(d.getMinutes()+2); + d.setMinutes(d.getMinutes() + 2); // setting the expiration pass.expiration(d.toLocaleString()); } - pass.generate().then(function(stream) { + pass.generate().then(function (stream) { response.set({ "Content-type": "application/vnd.apple.pkpass", "Content-disposition": `attachment; filename=${passName}.pkpass` diff --git a/examples/fields.js b/examples/fields.js index 45eb5be..4ef45b3 100644 --- a/examples/fields.js +++ b/examples/fields.js @@ -19,9 +19,9 @@ app.all(function manageRequest(request, response) { model: `./models/exampleBooking`, certificates: { wwdr: "../certificates/WWDR.pem", - signerCert: "../certificates/passcertificate.pem", + signerCert: "../certificates/signerCert.pem", signerKey: { - keyFile: "../certificates/passkey.pem", + keyFile: "../certificates/signerKey.pem", passphrase: "123456" } }, @@ -36,11 +36,11 @@ app.all(function manageRequest(request, response) { "value": "25 mag", "textAlignment": "PKTextAlignmentCenter" }, { - "key": "header2", - "label": "Volo", - "value": "EZY997", - "textAlignment": "PKTextAlignmentCenter" - }); + "key": "header2", + "label": "Volo", + "value": "EZY997", + "textAlignment": "PKTextAlignmentCenter" + }); pass.primaryFields.push({ key: "IATA-source", @@ -48,11 +48,11 @@ app.all(function manageRequest(request, response) { label: "Napoli", textAlignment: "PKTextAlignmentLeft" }, { - key: "IATA-destination", - value: "VCE", - label: "Venezia Marco Polo", - textAlignment: "PKTextAlignmentRight" - }); + key: "IATA-destination", + value: "VCE", + label: "Venezia Marco Polo", + textAlignment: "PKTextAlignmentRight" + }); pass.secondaryFields.push({ "key": "secondary1", @@ -60,21 +60,21 @@ app.all(function manageRequest(request, response) { "value": "18:40", "textAlignment": "PKTextAlignmentCenter", }, { - "key": "sec2", - "label": "Partenze", - "value": "19:10", - "textAlignment": "PKTextAlignmentCenter" - }, { - "key": "sec3", - "label": "SB", - "value": "Sì", - "textAlignment": "PKTextAlignmentCenter" - }, { - "key": "sec4", - "label": "Imbarco", - "value": "Anteriore", - "textAlignment": "PKTextAlignmentCenter" - }); + "key": "sec2", + "label": "Partenze", + "value": "19:10", + "textAlignment": "PKTextAlignmentCenter" + }, { + "key": "sec3", + "label": "SB", + "value": "Sì", + "textAlignment": "PKTextAlignmentCenter" + }, { + "key": "sec4", + "label": "Imbarco", + "value": "Anteriore", + "textAlignment": "PKTextAlignmentCenter" + }); pass.auxiliaryFields.push({ "key": "aux1", @@ -82,11 +82,11 @@ app.all(function manageRequest(request, response) { "value": "MR. WHO KNOWS", "textAlignment": "PKTextAlignmentLeft" }, { - "key": "aux2", - "label": "Posto", - "value": "1A*", - "textAlignment": "PKTextAlignmentCenter" - }); + "key": "aux2", + "label": "Posto", + "value": "1A*", + "textAlignment": "PKTextAlignmentCenter" + }); pass.backFields.push({ "key": "document number", @@ -94,58 +94,58 @@ app.all(function manageRequest(request, response) { "value": "- -", "textAlignment": "PKTextAlignmentLeft" }, { - "key": "You're checked in, what next", - "label": "Hai effettuato il check-in, Quali sono le prospettive", - "value": "", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "Check In", - "label": "1. check-in✓", - "value": "", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "checkIn", - "label": "", - "value": "Le uscite d'imbarco chiudono 30 minuti prima della partenza, quindi sii puntuale. In questo aeroporto puoi utilizzare la corsia Fast Track ai varchi di sicurezza.", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "2. Bags", - "label": "2. Bagaglio", - "value": "", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "Require special assistance", - "label": "Assistenza speciale", - "value": "Se hai richiesto assistenza speciale, presentati a un membro del personale nell'area di Consegna bagagli almeno 90 minuti prima del volo.", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "3. Departures", - "label": "3. Partenze", - "value": "", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "photoId", - "label": "Un documento d’identità corredato di fotografia", - "value": "è obbligatorio su TUTTI i voli. Per un viaggio internazionale è necessario un passaporto valido o, dove consentita, una carta d’identità.", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "yourSeat", - "label": "Il tuo posto:", - "value": "verifica il tuo numero di posto nella parte superiore. Durante l’imbarco utilizza le scale anteriori e posteriori: per le file 1-10 imbarcati dalla parte anteriore; per le file 11-31 imbarcati dalla parte posteriore. Colloca le borse di dimensioni ridotte sotto il sedile davanti a te.", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "Pack safely", - "label": "Bagaglio sicuro", - "value": "Fai clic http://easyjet.com/it/articoli-pericolosi per maggiori informazioni sulle merci pericolose oppure visita il sito CAA http://www.caa.co.uk/default.aspx?catid=2200", - "textAlignment": "PKTextAlignmentLeft" - }, { - "key": "Thank you for travelling easyJet", - "label": "Grazie per aver viaggiato con easyJet", - "value": "", - "textAlignment": "PKTextAlignmentLeft" - }); + "key": "You're checked in, what next", + "label": "Hai effettuato il check-in, Quali sono le prospettive", + "value": "", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "Check In", + "label": "1. check-in✓", + "value": "", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "checkIn", + "label": "", + "value": "Le uscite d'imbarco chiudono 30 minuti prima della partenza, quindi sii puntuale. In questo aeroporto puoi utilizzare la corsia Fast Track ai varchi di sicurezza.", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "2. Bags", + "label": "2. Bagaglio", + "value": "", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "Require special assistance", + "label": "Assistenza speciale", + "value": "Se hai richiesto assistenza speciale, presentati a un membro del personale nell'area di Consegna bagagli almeno 90 minuti prima del volo.", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "3. Departures", + "label": "3. Partenze", + "value": "", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "photoId", + "label": "Un documento d’identità corredato di fotografia", + "value": "è obbligatorio su TUTTI i voli. Per un viaggio internazionale è necessario un passaporto valido o, dove consentita, una carta d’identità.", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "yourSeat", + "label": "Il tuo posto:", + "value": "verifica il tuo numero di posto nella parte superiore. Durante l’imbarco utilizza le scale anteriori e posteriori: per le file 1-10 imbarcati dalla parte anteriore; per le file 11-31 imbarcati dalla parte posteriore. Colloca le borse di dimensioni ridotte sotto il sedile davanti a te.", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "Pack safely", + "label": "Bagaglio sicuro", + "value": "Fai clic http://easyjet.com/it/articoli-pericolosi per maggiori informazioni sulle merci pericolose oppure visita il sito CAA http://www.caa.co.uk/default.aspx?catid=2200", + "textAlignment": "PKTextAlignmentLeft" + }, { + "key": "Thank you for travelling easyJet", + "label": "Grazie per aver viaggiato con easyJet", + "value": "", + "textAlignment": "PKTextAlignmentLeft" + }); - pass.generate().then(function(stream) { + pass.generate().then(function (stream) { response.set({ "Content-type": "application/vnd.apple.pkpass", "Content-disposition": `attachment; filename=${passName}.pkpass` diff --git a/examples/localization.js b/examples/localization.js index d9df192..720338d 100644 --- a/examples/localization.js +++ b/examples/localization.js @@ -15,9 +15,9 @@ app.all(function manageRequest(request, response) { model: `./models/${request.params.modelName}`, certificates: { wwdr: "../certificates/WWDR.pem", - signerCert: "../certificates/passcertificate.pem", + signerCert: "../certificates/signerCert.pem", signerKey: { - keyFile: "../certificates/passkey.pem", + keyFile: "../certificates/signerKey.pem", passphrase: "123456" } }, @@ -53,7 +53,7 @@ app.all(function manageRequest(request, response) { console.log("Added languages", Object.keys(pass.l10n).join(", ")) - pass.generate().then(function(stream) { + pass.generate().then(function (stream) { response.set({ "Content-type": "application/vnd.apple.pkpass", "Content-disposition": `attachment; filename=${passName}.pkpass` diff --git a/tests/index.js b/tests/index.js index 8a5c9b1..d0aaee3 100644 --- a/tests/index.js +++ b/tests/index.js @@ -11,16 +11,16 @@ const Passkit = require(".."); * Tests created upon Jasmine testing suite. */ -describe("Node-Passkit-generator", function() { +describe("Node-Passkit-generator", function () { let pass; beforeEach(() => { pass = new Passkit.Pass({ model: "../examples/examplePass.pass", certificates: { - wwdr: "certs/WWDR.pem", - signerCert: "certs/signerCert.pem", + wwdr: "certificates/WWDR.pem", + signerCert: "certificates/signerCert.pem", signerKey: { - key: "certs/signerKey.pem", + keyFile: "certificates/signerKey.pem", passphrase: "123456" } }, @@ -69,17 +69,17 @@ describe("Node-Passkit-generator", function() { it("A date with defined format DD-MM-YYYY will apply changes", () => { pass.expiration("10-04-2021", "DD-MM-YYYY"); - expect(pass._props["expirationDate"]).toBe("2021-04-10T00:00:00+02:00"); + expect(pass._props["expirationDate"]).toBe("2021-04-10T00:00:00+01:00"); }); it("A date with undefined custom format, will apply changes", () => { pass.expiration("10-04-2021"); - expect(pass._props["expirationDate"]).toBe("2021-10-04T00:00:00+02:00"); + expect(pass._props["expirationDate"]).toBe("2021-10-04T00:00:00+01:00"); }); it("A date with defined format but with slashes will apply changes", () => { pass.expiration("10/04/2021", "DD-MM-YYYY"); - expect(pass._props["expirationDate"]).toBe("2021-04-10T00:00:00+02:00"); + expect(pass._props["expirationDate"]).toBe("2021-04-10T00:00:00+01:00"); }); it("An invalid date, will not apply changes", () => { @@ -87,7 +87,7 @@ describe("Node-Passkit-generator", function() { expect(pass._props["expirationDate"]).toBe(undefined); pass.expiration("32/18/228317", "DD-MM-YYYY"); - expect(pass._props["expirationDate"]).toBe(undefined); + expect(pass._props["expirationDate"]).toBe(undefined); }); }); @@ -95,17 +95,17 @@ describe("Node-Passkit-generator", function() { describe("relevance('relevantDate')", () => { it("A date with defined format DD-MM-YYYY will apply changes", () => { pass.relevance("relevantDate", "10-04-2021", "DD-MM-YYYY"); - expect(pass._props["relevantDate"]).toBe("2021-04-10T00:00:00+02:00"); + expect(pass._props["relevantDate"]).toBe("2021-04-10T00:00:00+01:00"); }); it("A date with undefined custom format, will apply changes", () => { pass.relevance("relevantDate", "10-04-2021"); - expect(pass._props["relevantDate"]).toBe("2021-10-04T00:00:00+02:00"); + expect(pass._props["relevantDate"]).toBe("2021-10-04T00:00:00+01:00"); }); it("A date with defined format but with slashes will apply changes", () => { pass.relevance("relevantDate", "10/04/2021", "DD-MM-YYYY"); - expect(pass._props["relevantDate"]).toBe("2021-04-10T00:00:00+02:00"); + expect(pass._props["relevantDate"]).toBe("2021-04-10T00:00:00+01:00"); }); }); @@ -237,7 +237,7 @@ describe("Node-Passkit-generator", function() { }); describe("barcode().backward()", () => { - it("Passing argument of type different from string or null, won't apply changes", function() { + it("Passing argument of type different from string or null, won't apply changes", function () { pass .barcode("Message-22645272183") .backward(5);