Uniformed filenames for certificates, fixed some problems in tests (maybe related to legal/solar time?)

This commit is contained in:
Alexander Cerutti
2018-11-07 12:35:07 +01:00
parent 48e6755082
commit 7624a895e0
5 changed files with 105 additions and 105 deletions

View File

@@ -19,9 +19,9 @@ app.all(function manageRequest(request, response) {
model: `./models/${request.params.modelName}`, model: `./models/${request.params.modelName}`,
certificates: { certificates: {
wwdr: "../certificates/WWDR.pem", wwdr: "../certificates/WWDR.pem",
signerCert: "../certificates/passcertificate.pem", signerCert: "../certificates/signerCert.pem",
signerKey: { signerKey: {
keyFile: "../certificates/passkey.pem", keyFile: "../certificates/signerKey.pem",
passphrase: "123456" passphrase: "123456"
} }
}, },
@@ -71,7 +71,7 @@ app.all(function manageRequest(request, response) {
console.log("Barcode property is now:", pass._props["barcode"]); console.log("Barcode property is now:", pass._props["barcode"]);
console.log("Barcodes support is autocompleted:", pass._props["barcodes"]); console.log("Barcodes support is autocompleted:", pass._props["barcodes"]);
pass.generate().then(function(stream) { pass.generate().then(function (stream) {
response.set({ response.set({
"Content-type": "application/vnd.apple.pkpass", "Content-type": "application/vnd.apple.pkpass",
"Content-disposition": `attachment; filename=${passName}.pkpass` "Content-disposition": `attachment; filename=${passName}.pkpass`

View File

@@ -22,9 +22,9 @@ app.all(function manageRequest(request, response) {
model: `./models/${request.params.modelName}`, model: `./models/${request.params.modelName}`,
certificates: { certificates: {
wwdr: "../certificates/WWDR.pem", wwdr: "../certificates/WWDR.pem",
signerCert: "../certificates/passcertificate.pem", signerCert: "../certificates/signerCert.pem",
signerKey: { signerKey: {
keyFile: "../certificates/passkey.pem", keyFile: "../certificates/signerKey.pem",
passphrase: "123456" passphrase: "123456"
} }
}, },
@@ -36,13 +36,13 @@ app.all(function manageRequest(request, response) {
} else if (request.query.fn === "expiration") { } else if (request.query.fn === "expiration") {
// 2 minutes later... // 2 minutes later...
let d = new Date(); let d = new Date();
d.setMinutes(d.getMinutes()+2); d.setMinutes(d.getMinutes() + 2);
// setting the expiration // setting the expiration
pass.expiration(d.toLocaleString()); pass.expiration(d.toLocaleString());
} }
pass.generate().then(function(stream) { pass.generate().then(function (stream) {
response.set({ response.set({
"Content-type": "application/vnd.apple.pkpass", "Content-type": "application/vnd.apple.pkpass",
"Content-disposition": `attachment; filename=${passName}.pkpass` "Content-disposition": `attachment; filename=${passName}.pkpass`

View File

@@ -19,9 +19,9 @@ app.all(function manageRequest(request, response) {
model: `./models/exampleBooking`, model: `./models/exampleBooking`,
certificates: { certificates: {
wwdr: "../certificates/WWDR.pem", wwdr: "../certificates/WWDR.pem",
signerCert: "../certificates/passcertificate.pem", signerCert: "../certificates/signerCert.pem",
signerKey: { signerKey: {
keyFile: "../certificates/passkey.pem", keyFile: "../certificates/signerKey.pem",
passphrase: "123456" passphrase: "123456"
} }
}, },
@@ -145,7 +145,7 @@ app.all(function manageRequest(request, response) {
"textAlignment": "PKTextAlignmentLeft" "textAlignment": "PKTextAlignmentLeft"
}); });
pass.generate().then(function(stream) { pass.generate().then(function (stream) {
response.set({ response.set({
"Content-type": "application/vnd.apple.pkpass", "Content-type": "application/vnd.apple.pkpass",
"Content-disposition": `attachment; filename=${passName}.pkpass` "Content-disposition": `attachment; filename=${passName}.pkpass`

View File

@@ -15,9 +15,9 @@ app.all(function manageRequest(request, response) {
model: `./models/${request.params.modelName}`, model: `./models/${request.params.modelName}`,
certificates: { certificates: {
wwdr: "../certificates/WWDR.pem", wwdr: "../certificates/WWDR.pem",
signerCert: "../certificates/passcertificate.pem", signerCert: "../certificates/signerCert.pem",
signerKey: { signerKey: {
keyFile: "../certificates/passkey.pem", keyFile: "../certificates/signerKey.pem",
passphrase: "123456" passphrase: "123456"
} }
}, },
@@ -53,7 +53,7 @@ app.all(function manageRequest(request, response) {
console.log("Added languages", Object.keys(pass.l10n).join(", ")) console.log("Added languages", Object.keys(pass.l10n).join(", "))
pass.generate().then(function(stream) { pass.generate().then(function (stream) {
response.set({ response.set({
"Content-type": "application/vnd.apple.pkpass", "Content-type": "application/vnd.apple.pkpass",
"Content-disposition": `attachment; filename=${passName}.pkpass` "Content-disposition": `attachment; filename=${passName}.pkpass`

View File

@@ -11,16 +11,16 @@ const Passkit = require("..");
* Tests created upon Jasmine testing suite. * Tests created upon Jasmine testing suite.
*/ */
describe("Node-Passkit-generator", function() { describe("Node-Passkit-generator", function () {
let pass; let pass;
beforeEach(() => { beforeEach(() => {
pass = new Passkit.Pass({ pass = new Passkit.Pass({
model: "../examples/examplePass.pass", model: "../examples/examplePass.pass",
certificates: { certificates: {
wwdr: "certs/WWDR.pem", wwdr: "certificates/WWDR.pem",
signerCert: "certs/signerCert.pem", signerCert: "certificates/signerCert.pem",
signerKey: { signerKey: {
key: "certs/signerKey.pem", keyFile: "certificates/signerKey.pem",
passphrase: "123456" passphrase: "123456"
} }
}, },
@@ -69,17 +69,17 @@ describe("Node-Passkit-generator", function() {
it("A date with defined format DD-MM-YYYY will apply changes", () => { it("A date with defined format DD-MM-YYYY will apply changes", () => {
pass.expiration("10-04-2021", "DD-MM-YYYY"); 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", () => { it("A date with undefined custom format, will apply changes", () => {
pass.expiration("10-04-2021"); 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", () => { it("A date with defined format but with slashes will apply changes", () => {
pass.expiration("10/04/2021", "DD-MM-YYYY"); 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", () => { it("An invalid date, will not apply changes", () => {
@@ -95,17 +95,17 @@ describe("Node-Passkit-generator", function() {
describe("relevance('relevantDate')", () => { describe("relevance('relevantDate')", () => {
it("A date with defined format DD-MM-YYYY will apply changes", () => { it("A date with defined format DD-MM-YYYY will apply changes", () => {
pass.relevance("relevantDate", "10-04-2021", "DD-MM-YYYY"); 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", () => { it("A date with undefined custom format, will apply changes", () => {
pass.relevance("relevantDate", "10-04-2021"); 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", () => { it("A date with defined format but with slashes will apply changes", () => {
pass.relevance("relevantDate", "10/04/2021", "DD-MM-YYYY"); 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()", () => { 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 pass
.barcode("Message-22645272183") .barcode("Message-22645272183")
.backward(5); .backward(5);