Skip to content

Commit

Permalink
expose mini nodeset2.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Apr 13, 2023
1 parent db064fb commit d7dd873
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 57 deletions.
1 change: 1 addition & 0 deletions packages/node-opcua-address-space/package.json
Expand Up @@ -93,6 +93,7 @@
"src",
"nodeJS.d.ts",
"nodeJS.js",
"nodesets",
"testHelpers.js",
"testHelpers.d.ts",
"source_nodejs"
Expand Down
Expand Up @@ -35,7 +35,7 @@ function callGarbageCollector() {
describe("Testing AddressSpace memory Leaks", function (this: any) {
this.timeout(Math.max(120*1000,this.timeout()));

const xml_file = path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const xml_file = path.join(__dirname, "../nodesets/mini.Nodeset2.xml");
fs.existsSync(xml_file).should.be.eql(true, "cannot find mini node set");

it("It should dispose an address_space", async () => {
Expand Down
Expand Up @@ -33,7 +33,7 @@ describe("testing address space namespace loading", function (this: any) {
it("should process namespaces and translate namespace index when loading node set xml files", async () => {
const addressSpace = AddressSpace.create();
const xml_files = [
path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml"),
path.join(__dirname, "../nodesets/mini.Nodeset2.xml"),
getFixture("fixture_custom_nodeset.xml")
];
fs.existsSync(xml_files[0]).should.be.eql(true);
Expand Down Expand Up @@ -72,7 +72,7 @@ describe("testing address space namespace loading", function (this: any) {
it("should process multiple xml files that reference each other", async () => {
const addressSpace = AddressSpace.create();
const xml_files = [
path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml"),
path.join(__dirname, "../nodesets/mini.Nodeset2.xml"),
getFixture("fixture_custom_nodeset.xml"),
getFixture("fixture_custom_nodeset_extension.xml")
];
Expand Down
Expand Up @@ -10,7 +10,7 @@ import { AddressSpace, Namespace } from "..";
import { generateAddressSpace } from "../nodeJS";
import { isArgumentValid } from "../source/helpers/argument_list";

const nodesetFilename = path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const nodesetFilename = path.join(__dirname, "../nodesets/mini.Nodeset2.xml");

interface TestCase {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/node-opcua-address-space/test/test_issue_104.ts
Expand Up @@ -10,7 +10,7 @@ import { AddressSpace, Namespace } from "..";
import { assertHasMatchingReference } from "../testHelpers";
import { generateAddressSpace } from "../nodeJS";

const nodesetFilename = path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const nodesetFilename = path.join(__dirname, "../nodesets/mini.Nodeset2.xml");

// tslint:disable-next-line:no-var-requires
const describe = require("node-opcua-leak-detector").describeWithLeakDetector;
Expand Down
2 changes: 1 addition & 1 deletion packages/node-opcua-address-space/test/test_issue_312.ts
Expand Up @@ -22,7 +22,7 @@ describe("Issue 132", function (this: any) {
});

it("#312 - should load a nodeset xml file containing MandatoryPlaceHolder f", async () => {
const xml_file0 = path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const xml_file0 = path.join(__dirname, "../nodesets/mini.Nodeset2.xml");
const xml_file1 = getFixture("fixture_issue_312_nodeset2.xml");

fs.existsSync(xml_file0).should.be.eql(true);
Expand Down
8 changes: 4 additions & 4 deletions packages/node-opcua-address-space/test/test_load_nodeset2.ts
Expand Up @@ -42,7 +42,7 @@ describe("testing NodeSet XML file loading", function (this: any) {
});

it("should load a nodeset xml file", async () => {
const xml_file = path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const xml_file = path.join(__dirname, "../nodesets/mini.Nodeset2.xml");

fs.existsSync(xml_file).should.be.eql(true);

Expand Down Expand Up @@ -162,7 +162,7 @@ describe("testing NodeSet XML file loading", function (this: any) {
});

it("Q1 should read a VariableType with a default value", async () => {
const xml_file1 = path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const xml_file1 = path.join(__dirname, "../nodesets/mini.Nodeset2.xml");
const xml_file2 = getFixture("fixture_variable_type_with_default_value.xml");

const xml_files = [xml_file1, xml_file2];
Expand Down Expand Up @@ -228,7 +228,7 @@ describe("testing NodeSet XML file loading", function (this: any) {
});

it("VV3 should load a nodeset from UAModeler", async () => {
const xml_file1 = nodesets.standard; // path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const xml_file1 = nodesets.standard; // path.join(__dirname, "../nodesets/mini.Nodeset2.xml");
const xml_file2 = path.join(__dirname, "../../../modeling/my_data_type.xml");
const xml_files = [xml_file1, xml_file2];
await generateAddressSpace(addressSpace, xml_files);
Expand Down Expand Up @@ -617,7 +617,7 @@ describe("Testing variables loading ", function (this: any) {
namespace0._dataTypeCount().should.equal(0);
namespace0._objectTypeCount().should.equal(0);

const xml_file1 = path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const xml_file1 = path.join(__dirname, "../nodesets/mini.Nodeset2.xml");

const xml_file = path.join(__dirname, "../test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml");
fs.existsSync(xml_file).should.be.eql(true);
Expand Down
9 changes: 7 additions & 2 deletions packages/node-opcua-address-space/test/test_variable.ts
Expand Up @@ -12,7 +12,7 @@ import { WriteValue, WriteValueOptions } from "node-opcua-types";
import { StatusCodeCallback } from "node-opcua-status-code";
import { VariableTypeIds } from "node-opcua-constants";

const nodeset_filename = path.join(__dirname, "../test_helpers/test_fixtures/mini.Node.Set2.xml");
const nodeset_filename = path.join(__dirname, "../nodesets/mini.Nodeset2.xml");

import {
AddressSpace,
Expand All @@ -26,6 +26,7 @@ import {
import { generateAddressSpace } from "../nodeJS";

import { create_minimalist_address_space_nodeset } from "../testHelpers";
import { getCurrentClock } from "node-opcua-date-time";

const context = SessionContext.defaultContext;

Expand Down Expand Up @@ -490,7 +491,7 @@ describe("testing Variable#bindVariable", () => {
dataValueCheck1.statusCode.should.eql(StatusCodes.UncertainInitialValue);

// call_refresh
await variable.asyncRefresh(new Date());
await variable.asyncRefresh(getCurrentClock());

// read_simple_value_after_refresh
const dataValueCheck2 = variable.readValue();
Expand Down Expand Up @@ -1410,3 +1411,7 @@ describe("testing UAVariable ", () => {
statusCode1.should.eql(StatusCodes.Good);
});
});
function geCurrentClock(): import("node-opcua-date-time").PreciseClock {
throw new Error("Function not implemented.");
}

Expand Up @@ -5,8 +5,17 @@ import * as fs from "fs";
import * as path from "path";

export function getAddressSpaceFixture(pathname: string): string {
// find test_fixtures


// find in nodesets folder in the first place
const folder1 = path.join(__dirname, "../nodesets");
if (fs.existsSync(folder1)) {
const filename = path.join(folder1, pathname);
if (fs.existsSync(filename)) {
return filename;
}
}

// find in test_fixtures seconds
let folder = path.join(__dirname, "./test_fixtures");
if (!fs.existsSync(folder)) {
folder = path.join(__dirname, "../test_helpers/test_fixtures");
Expand Down
Expand Up @@ -8,7 +8,7 @@ import { generateAddressSpace } from "../nodeJS";

import { getAddressSpaceFixture } from "./get_address_space_fixture";

export const mini_nodeset = "mini.Node.Set2.xml";
export const mini_nodeset = "mini.Nodeset2.xml";
export const empty_nodeset = "fixture_empty_nodeset2.xml";

export const get_mini_nodeset_filename = (): string => getAddressSpaceFixture(mini_nodeset);
Expand Down
Expand Up @@ -4,19 +4,23 @@ const should = require("should");
const async = require("async");
const sinon = require("sinon");

const opcua = require("node-opcua");
const {
OPCUAServer,
OPCUAClientBase,
OPCUAClient,
StatusCodes,
MessageSecurityMode,
SecurityPolicy,
CreateSessionRequest,
get_empty_nodeset_filename
}= require("node-opcua");

const OPCUAServer = opcua.OPCUAServer;
const OPCUAClient = opcua.OPCUAClient;
const OPCUAClientBase = opcua.OPCUAClientBase;

const StatusCodes = opcua.StatusCodes;

const { SignatureData } = require("node-opcua-service-secure-channel");

const port = 2237;

const empty_nodeset_filename = opcua.get_empty_nodeset_filename();
const empty_nodeset_filename = get_empty_nodeset_filename();

const crypto_utils = require("node-opcua-crypto");

Expand All @@ -36,8 +40,8 @@ describe("testing the server ability to deny client session request (server with
const serverCertificate = server.getCertificateChain();

options = {
securityMode: opcua.MessageSecurityMode.SignAndEncrypt,
securityPolicy: opcua.SecurityPolicy.Basic256,
securityMode: MessageSecurityMode.SignAndEncrypt,
securityPolicy: SecurityPolicy.Basic256,
serverCertificate: serverCertificate,
defaultSecureTokenLifetime: 2000
};
Expand Down Expand Up @@ -199,7 +203,7 @@ describe("testing the server ability to deny client session request (server with

function(callback) {

const createSessionRequest = new opcua.CreateSessionRequest({
const createSessionRequest = new CreateSessionRequest({
requestHeader: {},
clientNonce: Buffer.alloc(31)
});
Expand All @@ -225,8 +229,8 @@ describe("testing the server ability to deny client session request (server with

// in this case, server certificate will be extracted from the getPoint Information
const options = {
securityMode: opcua.MessageSecurityMode.SignAndEncrypt,
securityPolicy: opcua.SecurityPolicy.Basic256,
securityMode: MessageSecurityMode.SignAndEncrypt,
securityPolicy: SecurityPolicy.Basic256,
serverCertificate: null, // NOT KNOWN
defaultSecureTokenLifetime: 2000
};
Expand Down
11 changes: 3 additions & 8 deletions packages/node-opcua-end2end-test/test/test_secure_server.js
Expand Up @@ -2,13 +2,7 @@
const should = require("should");
const async = require("async");

const opcua = require("node-opcua");
const OPCUAServer = opcua.OPCUAServer;
const OPCUAClient = opcua.OPCUAClient;
const SecurityPolicy = opcua.SecurityPolicy;
const MessageSecurityMode = opcua.MessageSecurityMode;

const empty_nodeset_filename = opcua.get_empty_nodeset_filename();
const { EndpointDescription, OPCUAServer, OPCUAClient, SecurityPolicy, MessageSecurityMode, get_empty_nodeset_filename } = require("node-opcua");
/*
Discovery Endpoints shall not require any message security, but it may require transport layer
security. In production systems, Administrators may disable discovery for security reasons and
Expand Down Expand Up @@ -38,6 +32,7 @@ describe("testing behavior of secure Server ( server that only accept Sign or Si

this.timeout(Math.max(20000, this.timeout()));

const empty_nodeset_filename = get_empty_nodeset_filename();
const port = 2241;
before(async () => {
const serverCertificateManager = await createServerCertificateManager(port);
Expand Down Expand Up @@ -87,7 +82,7 @@ describe("testing behavior of secure Server ( server that only accept Sign or Si
// establishing a session. Let's inject a fake unsecure endpoint so we can
// skip the internal client test for invalid endpoint and get to the server

const unsecureEndpoint = new opcua.EndpointDescription(client._serverEndpoints[0]);
const unsecureEndpoint = new EndpointDescription(client._serverEndpoints[0]);
unsecureEndpoint.securityMode = MessageSecurityMode.None;
unsecureEndpoint.securityPolicyUri = SecurityPolicy.None;

Expand Down
@@ -1,58 +1,49 @@
const should = require("should");
const { assert } = require("node-opcua-assert");

const opcua = require("node-opcua");

const OPCUAServer = opcua.OPCUAServer;
const OPCUAClient = opcua.OPCUAClient;
const { OPCUAServer, OPCUAClient, get_empty_nodeset_filename, is_valid_endpointUrl } = require("node-opcua");

const { make_debugLog, checkDebugFlag } = require("node-opcua-debug");
const debugLog = make_debugLog("TEST");
const doDebug = checkDebugFlag("TEST");

const empty_nodeset_filename = opcua.get_empty_nodeset_filename();

const empty_nodeset_filename = get_empty_nodeset_filename();

async function build_client_server_session(options) {

assert(options.port, "must provide a port number");
let endpointUrl;
const server = new OPCUAServer(options);
const client = OPCUAClient.create({});


await server.start();

// we will connect to first server end point
endpointUrl = server.getEndpointUrl();
debugLog("endpointUrl", endpointUrl);
opcua.is_valid_endpointUrl(endpointUrl).should.equal(true);

is_valid_endpointUrl(endpointUrl).should.equal(true);

await client.connect(endpointUrl);
const session = await client.createSession();
const session = await client.createSession();

async function shutdown() {

// let's verify that the server has got at least one session active (the one we created above)
assert(server.engine.currentSessionCount >= 1, "expecting at least one active session on service side");
assert(client_server.g_session);

await client_server.g_session.close();

// disconnect client abruptly
// disconnect client abruptly
await client.disconnect();

//xx // disconnecting the client should have cause the server to discard the subscriptions
//xx assert(server.engine.currentSessionCount === 0);

// OK, it is now time to shutdown the server.
await server.shutdown();
//xx // disconnecting the client should have cause the server to discard the subscriptions
//xx assert(server.engine.currentSessionCount === 0);

// let's perform some more verification
assert(server.engine.currentSessionCount === 0);
assert(server.engine.currentSubscriptionCount === 0);
// OK, it is now time to shutdown the server.
await server.shutdown();

// let's perform some more verification
assert(server.engine.currentSessionCount === 0);
assert(server.engine.currentSubscriptionCount === 0);
}

const client_server = {
Expand Down

0 comments on commit d7dd873

Please sign in to comment.