本文整理匯總了TypeScript中node-opcua-test-fixtures.getFixture函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getFixture函數的具體用法?TypeScript getFixture怎麽用?TypeScript getFixture使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getFixture函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
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_file2 = getFixture("fixture_variable_type_with_default_value.xml");
const xml_files = [
xml_file1, xml_file2
];
await generateAddressSpace(addressSpace, xml_files);
const ns = addressSpace.getNamespaceIndex("MYNAMESPACE");
ns.should.eql(1);
const my3x3MatrixType = addressSpace.findVariableType("My3x3MatrixType", ns)!;
should.exist(my3x3MatrixType);
my3x3MatrixType.browseName.toString().should.eql("1:My3x3MatrixType");
addressSpace.findDataType(my3x3MatrixType.dataType)!.browseName.toString().should.eql("Float");
my3x3MatrixType.valueRank.should.eql(2);
my3x3MatrixType.arrayDimensions.should.eql([3, 3]);
(my3x3MatrixType as any).value.toString().should.eql(new Variant({
dataType: "Float", value: [11, 12, 13, 21, 22, 23, 31, 32, 33]
}).toString());
const myDoubleArrayType = addressSpace.findVariableType("MyDoubleArrayType", ns)!;
myDoubleArrayType.browseName.toString().should.eql("1:MyDoubleArrayType");
myDoubleArrayType.valueRank.should.eql(1);
myDoubleArrayType.arrayDimensions.should.eql([5]);
(myDoubleArrayType as any).value.toString().should.eql(
new Variant({ dataType: "Double", value: [1, 2, 3, 4, 5] }).toString());
});
示例2: it
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"),
getFixture("fixture_custom_nodeset.xml"),
getFixture("fixture_custom_nodeset_extension.xml")
];
fs.existsSync(xml_files[0]).should.be.eql(true);
fs.existsSync(xml_files[1]).should.be.eql(true);
fs.existsSync(xml_files[2]).should.be.eql(true);
addressSpace.registerNamespace("ServerNamespaceURI");
addressSpace.getNamespaceArray().length.should.eql(2);
await generateAddressSpace(addressSpace, xml_files);
addressSpace.getNamespaceArray().length.should.eql(5);
addressSpace.getNamespaceArray()[2].namespaceUri.should.eql("http://nodeopcua.org/UA/CUSTOM_NAMESPACE1/");
addressSpace.getNamespaceArray()[3].namespaceUri.should.eql("http://nodeopcua.org/UA/CUSTOM_NAMESPACE2/");
addressSpace.getNamespaceArray()[4].namespaceUri.should.eql("http://nodeopcua.org/UA/CUSTOM_NAMESPACE3/");
addressSpace.findNode("ns=2;i=1")!.browseName.toString().should.eql("2:ObjectInCUSTOM_NAMESPACE1");
addressSpace.findNode("ns=3;i=1")!.browseName.toString().should.eql("3:ObjectInCUSTOM_NAMESPACE2");
addressSpace.findNode("ns=2;i=1000")!.browseName.toString().should.eql("2:AnOtherObjectInCUSTOM_NAMESPACE1");
addressSpace.findNode("ns=3;i=1000")!.browseName.toString().should.eql("3:AnOtherObjectInCUSTOM_NAMESPACE2");
addressSpace.findNode("ns=4;i=1")!.browseName.toString().should.eql("4:ObjectInCUSTOM_NAMESPACE3");
addressSpace.getNamespaceArray().map((x) => x.namespaceUri).should.eql([
"http://opcfoundation.org/UA/",
"ServerNamespaceURI",
"http://nodeopcua.org/UA/CUSTOM_NAMESPACE1/",
"http://nodeopcua.org/UA/CUSTOM_NAMESPACE2/",
"http://nodeopcua.org/UA/CUSTOM_NAMESPACE3/"
]);
addressSpace.dispose();
});
示例3: construct_verifyMessageChunkSignatureForTest
export function construct_verifyMessageChunkSignatureForTest() {
const publicKey = fs.readFileSync(getFixture("certs/server_public_key_1024.pub")).toString("ascii");
return (chunk: Buffer) => {
assert(chunk instanceof Buffer);
const options = {
algorithm: "RSA-SHA256",
publicKey,
signatureLength: 128
};
return verifyChunkSignature(chunk, options);
};
}
示例4: construct_makeMessageChunkSignatureForTest
function construct_makeMessageChunkSignatureForTest() {
const privateKey = fs.readFileSync(getFixture("certs/server_key_1024.pem")).toString("ascii");
return (chunk: Buffer) => {
const options = {
algorithm: "RSA-SHA256",
privateKey,
signatureLength: 128,
};
const buf = makeMessageChunkSignature(chunk, options); // Buffer
assert(buf instanceof Buffer, "expecting a Buffer");
return buf;
};
}
示例5: it
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_file1 = getFixture("fixture_issue_312_nodeset2.xml");
fs.existsSync(xml_file0).should.be.eql(true);
fs.existsSync(xml_file1).should.be.eql(true);
const xml_files = [
xml_file0,
xml_file1
];
await generateAddressSpace(addressSpace, xml_files);
});
示例6: require
encryptBufferWithDerivedKeys,
makeMessageChunkSignature,
makeMessageChunkSignatureWithDerivedKeys,
makeSHA1Thumbprint,
publicEncrypt_long,
readCertificate,
readKeyPem,
RSA_PKCS1_PADDING
} from "node-opcua-crypto";
import { AsymmetricAlgorithmSecurityHeader, SymmetricAlgorithmSecurityHeader } from "node-opcua-service-secure-channel";
import { SecureMessageChunkManager, SequenceNumberGenerator } from "../source";
// tslint:disable:no-var-requires
const getFixture = require("node-opcua-test-fixtures").getFixture;
const senderCertificate = readCertificate(getFixture("certs/client_cert_1024.pem"));
const senderPrivateKey = readKeyPem(getFixture("certs/client_key_1024.pem"));
const receiverCertificate = readCertificate(getFixture("certs/server_cert_1024.pem"));
const receiverCertificateThumbprint = makeSHA1Thumbprint(receiverCertificate);
const receiverPublicKey = fs.readFileSync(getFixture("certs/server_public_key_1024.pub", "ascii")).toString();
const sequenceNumberGenerator = new SequenceNumberGenerator();
export type ChunkVisitorFunc = (err: Error | null, chunk?: Buffer) => void;
export function iterateOnSignedMessageChunks(buffer: Buffer, callback: ChunkVisitorFunc) {
const params = {
algorithm: "RSA-SHA1",