Skip to content

Commit

Permalink
travis should pass all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dnaganog committed Aug 14, 2019
1 parent fe2bbc7 commit d02bcf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
22 changes: 11 additions & 11 deletions __tests__/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,35 @@ describe("Tests for addService", () => {
});

// bind tests still need work, stopping jest process
xdescribe("Unit tests for bind.", () => {
xit("Bind should support a single port insecurely if no config supplied.", () => {
describe("Unit tests for bind.", () => {
it("Bind should support a single port insecurely if no config supplied.", () => {
const server = new Server();
const boundPorts = server.bind("0.0.0.0:3000");
server.bind("0.0.0.0:3000");
expect(server._ports.length).toBe(1);
});

xit("If no cert/key is passed with an array of ports, they are all generated but insecure.", () => {
it("If no cert/key is passed with an array of ports, they are all generated but insecure.", () => {
const server = new Server();
const boundPorts = server.bind(["0.0.0.0:3001", "0.0.0.0:3002"]);
server.bind(["0.0.0.0:3001", "0.0.0.0:3002"]);
expect(server._ports.length).toBe(2);
});

xit("Properly binds one SSL", () => {
it("Properly binds one SSL", () => {
const server = new Server();
let certPath = path.join(__dirname, "/test1.crt");
let keyPath = path.join(__dirname, "/test1.key");
const boundPorts = server.bind("0.0.0.0:3003", {
server.bind("0.0.0.0:3003", {
privateKey: keyPath,
certificate: certPath
});
expect(server._ports.length).toBe(1);
});

xit("If array of ports and certs/keys are passed each port at index in ports array is bound matching the cert at the same index of the certs array", () => {
it("If array of ports and certs/keys are passed each port at index in ports array is bound matching the cert at the same index of the certs array", () => {
const server = new Server();
let certPath = path.join(__dirname, "/test1.crt");
let keyPath = path.join(__dirname, "/test1.key");
const boundPorts = server.bind(
server.bind(
["0.0.0.0:3004", "0.0.0.0.3005"],
[
{
Expand All @@ -124,11 +124,11 @@ xdescribe("Unit tests for bind.", () => {
expect(server._ports.length).toBe(2);
});

xit("If one cert/key pair is passed, it is applied to all of the different ports.", () => {
it("If one cert/key pair is passed, it is applied to all of the different ports.", () => {
const server = new Server();
let certPath = path.join(__dirname, "/test1.crt");
let keyPath = path.join(__dirname, "/test1.key");
const boundPorts = server.bind(["0.0.0.0:3006", "0.0.0.0.3007"], {
server.bind(["0.0.0.0:3006", "0.0.0.0.3007"], {
privateKey: keyPath,
certificate: certPath
});
Expand Down
9 changes: 1 addition & 8 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ server.bind( '0.0.0.0:3000', {certificate, privateKey } )
const boundPorts = [];
let readCertificate;
let readPrivateKey;
if (typeof ports !== "string" && !sslConfigs) {
if (typeof ports !== "string" && !Array.isArray(ports) && !sslConfigs) {
throw new Error("PORT must be a string or array of strings.");
}
else if (typeof ports === "string" && !sslConfigs) {
Expand All @@ -193,7 +193,6 @@ server.bind( '0.0.0.0:3000', {certificate, privateKey } )
grpc.ServerCredentials.createInsecure(),
)
)
return this;
}
else if (typeof ports === "string" && !Array.isArray(sslConfigs) && typeof sslConfigs === 'object') {
readCertificate = fs.readFileSync(
Expand All @@ -214,7 +213,6 @@ server.bind( '0.0.0.0:3000', {certificate, privateKey } )
),
)
)
return this;
} else if (typeof ports === "string" && Array.isArray(sslConfigs)) {
readCertificate = fs.readFileSync(
sslConfigs[0].certificate
Expand All @@ -234,7 +232,6 @@ server.bind( '0.0.0.0:3000', {certificate, privateKey } )
),
)
)
return this;
} else if (Array.isArray(ports) && !sslConfigs) {
console.log(sslConfigs)
ports.forEach(port => {
Expand All @@ -245,7 +242,6 @@ server.bind( '0.0.0.0:3000', {certificate, privateKey } )
)
)
})
return this;
} else if (Array.isArray(ports) && !Array.isArray(sslConfigs) && typeof sslConfigs === 'object') {
readCertificate = fs.readFileSync(
sslConfigs.certificate
Expand All @@ -267,7 +263,6 @@ server.bind( '0.0.0.0:3000', {certificate, privateKey } )
)
)
})
return this;
} else if (Array.isArray(ports) && Array.isArray(sslConfigs) && ports.length !== sslConfigs.length) {
readCertificate = fs.readFileSync(
sslConfigs[0].certificate
Expand All @@ -289,7 +284,6 @@ server.bind( '0.0.0.0:3000', {certificate, privateKey } )
)
)
})
return this;
} else if (Array.isArray(ports) && Array.isArray(sslConfigs) && ports.length === sslConfigs.length) {
ports.forEach((port, index) => {
readCertificate = fs.readFileSync(
Expand All @@ -311,7 +305,6 @@ server.bind( '0.0.0.0:3000', {certificate, privateKey } )
)
)
})
return this;
}
// Future: support an array of ports or unlimited args
// let ports = [];
Expand Down

0 comments on commit d02bcf4

Please sign in to comment.