Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure policies are uniq in endpoints
- Loading branch information
1 parent
be3489e
commit 6607a4b
Showing
7 changed files
with
103 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require: | ||
- ../../node_modules/source-map-support/register | ||
- ../../node_modules/ts-node/register/transpile-only | ||
recursive: tue | ||
bail: true | ||
extension: | ||
- js | ||
- ts | ||
timeout: 500000 |
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
packages/node-opcua-end2end-test/test/test_verify_end_points.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { OPCUAServer, OPCUAClient } from "node-opcua"; | ||
import * as should from "should"; | ||
const _should = should; | ||
const port = 25400; | ||
|
||
const describe = require("node-opcua-leak-detector").describeWithLeakDetector; | ||
describe("Verifying Server Endpoint", () => { | ||
let server: OPCUAServer; | ||
let endpointUri: string = `opc.tcp://localhost:${port}`; | ||
before(async () => { | ||
server = new OPCUAServer({ port }); | ||
await server.initialize(); | ||
await server.start(); | ||
endpointUri = server.endpoints[0].endpointDescriptions()[0].endpointUrl!; | ||
}); | ||
|
||
after(async () => { | ||
await server.shutdown(); | ||
}); | ||
|
||
it("should not have duplicated policies", async () => { | ||
// given a server | ||
const client = OPCUAClient.create({ endpoint_must_exist: false }); | ||
|
||
await client.connect(endpointUri); | ||
|
||
const endpointDescriptions = await client.getEndpoints(); | ||
|
||
try { | ||
for (const e of endpointDescriptions) { | ||
// console.log(e.toString()); | ||
const policyIds = e.userIdentityTokens!.map((a) => a.policyId!); | ||
|
||
const counters: { [key: string]: number } = {}; | ||
policyIds?.forEach((a: string) => { | ||
counters[a] = (counters[a] || 0) + 1; | ||
}); | ||
const duplicatedPolicies = Object.entries(counters) | ||
.filter(([k, v]) => v !== 1) | ||
.map(([k, v]) => k); | ||
|
||
if (duplicatedPolicies.length) { | ||
console.log("duplicated policies", duplicatedPolicies); | ||
} | ||
|
||
duplicatedPolicies.should.eql([], "endpoint " + e.securityPolicyUri + " must not exhibit duplicated policies"); | ||
} | ||
} catch (err) { | ||
throw err; | ||
} finally { | ||
await client.disconnect(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters