Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Apr 25, 2021
1 parent 85456db commit eb56a9c
Show file tree
Hide file tree
Showing 20 changed files with 240 additions and 362 deletions.
2 changes: 1 addition & 1 deletion mods/agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@fonos/core": "^0.0.81",
"@fonos/logger": "^0.0.81",
"grpc": "^1.24.6",
"grpc": "^1.24.7",
"grpc-promise": "^1.4.0",
"grpc-ts-health-check": "^2.0.6"
},
Expand Down
31 changes: 31 additions & 0 deletions mods/agents/test/agents.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,37 @@ describe('Agents Service', () => {
})
})
context('agent decoder', () => {
const decoder = require('../dist/common/decoders/agent_decoder')
it('should create an agent object from a json object', () => {
const jsonObj = {
metadata: {
ref: '001',
name: 'Peter',
createdOn: 'DATE',
modifiedOn: 'DATE'
},
spec: {
credentials: {
username: 'peter',
secret: 'secret'
},
domains: ['sip.local']
}
}
const agent = decoder(jsonObj)
expect(agent.getRef()).to.be.equal(jsonObj.metadata.ref)
expect(agent.getName()).to.be.equal(jsonObj.metadata.name)
expect(agent.getCreateTime()).to.be.equal(jsonObj.metadata.createdOn)
expect(agent.getUpdateTime()).to.be.equal(jsonObj.metadata.modifiedOn)
expect(agent.getUsername()).to.be.equal(jsonObj.spec.credentials.username)
expect(agent.getSecret()).to.be.equal(jsonObj.spec.credentials.secret)
expect(agent.getDomainsList())
.to.be.a('array')
.lengthOf(1)
})
})
// The backend(routr) is failing at this
it.skip('Create agent missing username', done => {
agents
Expand Down
4 changes: 3 additions & 1 deletion mods/appmanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@
"@fonos/events": "^0.0.81",
"@fonos/errors": "^0.0.81",
"fs-extra": "^8.1.0",
"grpc": "^1.24.6",
"grpc-promise": "^1.4.0",
"grpc-ts-health-check": "^2.0.6",
"tar": "^6.0.1"
},
"peerDependencies": {
"grpc": "^1.24.7"
},
"devDependencies": {
"@types/fs-extra": "^9.0.1",
"@types/tar": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion mods/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@fonos/logger": "^0.0.81",
"grpc": "^1.24.6",
"grpc": "^1.24.7",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.12.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ describe("@fonos/core/commom", () => {
expect(next.calledOnce);
});
});
*/
});*/
2 changes: 1 addition & 1 deletion mods/callmanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@fonos/errors": "^0.0.81",
"@fonos/logger": "^0.0.81",
"ari-client": "^2.2.0",
"grpc": "^1.24.6",
"grpc": "^1.24.7",
"grpc-promise": "^1.4.0",
"grpc-ts-health-check": "^2.0.6",
"phone": "^2.4.21"
Expand Down
8 changes: 3 additions & 5 deletions mods/core/src/common/trust_util.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import logger from "@fonos/logger";
import {getSalt} from "@fonos/certs";
import path from "path";
import grpc from "grpc";
import jwt from "jsonwebtoken";
import * as os from "os";
import * as fs from "fs";
const atob = require("atob");
import atob from "atob";
import grpc from "grpc";

const prepCert = (cert: string) => Buffer.from(atob(cert), "utf-8");

Expand Down Expand Up @@ -46,7 +44,7 @@ const getServerCredentials = () => {
}
};

const getClientCredentials = () => {
const getClientCredentials = (grpc?) => {
try {
return grpc.credentials.createSsl(
prepCert(config.caCertificate),
Expand Down
2 changes: 1 addition & 1 deletion mods/core/src/service_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function run(srvInf: ServiceInf) {
const grpcHealthCheck = new GrpcHealthCheck(healthCheckStatusMap);
const server = new grpc.Server();

server.addService<unknown>(srvInf.service, srvInf.server);
server.addService(srvInf.service, srvInf.server);
server.addService(HealthService, grpcHealthCheck)
server.bind(ENDPOINT, getServerCredentials());
server.start();
Expand Down
Loading

0 comments on commit eb56a9c

Please sign in to comment.