Skip to content

Commit

Permalink
chore: improve code coverage and remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Jun 5, 2023
1 parent b96cec0 commit a8ef721
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,6 @@ function isChannelSecure(channel: IChannelBase): boolean {
return false;
}

function newIsUserReadable(this: BaseNode, context: ISessionContext): boolean {
if (context) {
if (!context.session) {
// console.log(" context has no session", context);
return false;
}
if (!context.session.channel) {
// console.log(" context has no channel", context);
return false;
}
if (!isChannelSecure(context.session.channel)) {
return false;
}
return true;
}
return false;
}

/**
* make sure that the given ia node can only be read
* by Administrator user on a encrypted channel
Expand Down Expand Up @@ -57,7 +39,6 @@ const restrictedAccessFlag = makeAccessRestrictionsFlag("SigningRequired | Encry
export function ensureObjectIsSecure(node: BaseNode): void {
node.setAccessRestrictions(restrictedAccessFlag);
if (node.nodeClass === NodeClass.Variable) {
// replaceMethod(node, "isUserReadable", newIsUserReadable);
const variable = node as UAVariable;
variable.setRolePermissions(restrictedPermissions);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// tslint:disable:no-console
import * as fs from "fs";
import * as path from "path";
import should from "should";
import "should";

import { AddressSpace } from "..";
import { generateAddressSpace } from "../nodeJS";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ describe("testing Client - Umbrella-A ", function () {
require("./u_test_e2e_call_service")(test);
require("./u_test_e2e_ClientSession_readVariableValue")(test);
require("./u_test_e2e_client_node_crawler")(test);
require("./u_test_e2e_ read_history_server_capabilities").t(test);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import should from "should";
import { OPCUAClient, readHistoryServerCapabilities } from "node-opcua-client";
export function t(test: any) {
describe("ReadHistoryServerCapabilities", function () {
it("should read history server capabilities", async () => {
const client = OPCUAClient.create({});
await client.withSessionAsync(test.endpointUrl, async (session) => {
const cap = await readHistoryServerCapabilities(session);

console.log(cap);

cap.accessHistoryDataCapability.value.should.eql(false);
cap.accessHistoryEventsCapability.value.should.eql(false);

cap.maxReturnDataValues.value.should.eql(0);
cap.maxReturnEventValues.value.should.eql(0);

cap.deleteAtTimeCapability.value.should.eql(false);
cap.deleteRawCapability.value.should.eql(false);
cap.deleteEventCapability.value.should.eql(false);
// cap.deleteAnnotationCapability.value.should.eql(false);

cap.insertAnnotationCapability.value.should.eql(false);
cap.insertDataCapability.value.should.eql(false);
cap.insertEventCapability.value.should.eql(false);

cap.replaceDataCapability.value.should.eql(false);
cap.replaceEventCapability.value.should.eql(false);
// cap.replaceAnnotationCapability.should.eql(false);

cap.updateEventCapability.value.should.eql(false);
cap.updateDataCapability.value.should.eql(false);
// cap.updateAnnotationCapability.should.eql(false);

should(cap["aggregateFunctions/AnnotationCount"].value).eql(null);
});
});
});
}

0 comments on commit a8ef721

Please sign in to comment.