3 from opcua
import Client
4 from opcua
import Server
11 print(
"WARNING: CRYPTO NOT AVAILABLE, CRYPTO TESTS DISABLED!!")
12 disable_crypto_tests =
True 14 disable_crypto_tests =
False 20 @unittest.skipIf(disable_crypto_tests,
"crypto not available")
24 Test connectino with a server supporting crypto 31 cls.
uri_crypto =
'opc.tcp://localhost:{0:d}'.format(port_num1)
35 cls.srv_crypto.load_certificate(
"examples/certificate-example.der")
36 cls.srv_crypto.load_private_key(
"examples/private-key-example.pem")
37 cls.srv_crypto.start()
43 cls.srv_no_crypto.start()
48 cls.srv_no_crypto.stop()
55 clt.get_objects_node().get_children()
61 with self.assertRaises(ua.UaError):
62 clt.set_security_string(
"Basic256,Sign,examples/certificate-example.der,examples/private-key-example.pem")
67 clt.set_security_string(
"Basic256,Sign,examples/certificate-example.der,examples/private-key-example.pem")
69 self.assertTrue(clt.get_objects_node().get_children())
76 clt.set_security_string(
"Basic256,SignAndEncrypt,examples/certificate-example.der,examples/private-key-example.pem")
78 self.assertTrue(clt.get_objects_node().get_children())
85 clt.set_security_string(
"Basic128Rsa15,Sign,examples/certificate-example.der,examples/private-key-example.pem")
87 self.assertTrue(clt.get_objects_node().get_children())
94 clt.set_security_string(
"Basic128Rsa15,SignAndEncrypt,examples/certificate-example.der,examples/private-key-example.pem")
96 self.assertTrue(clt.get_objects_node().get_children())
103 clt.set_security(security_policies.SecurityPolicyBasic256,
104 'examples/certificate-example.der',
105 'examples/private-key-example.pem',
107 ua.MessageSecurityMode.SignAndEncrypt
110 self.assertTrue(clt.get_objects_node().get_children())
117 with self.assertRaises(ua.UaError):
118 clt.set_security(security_policies.SecurityPolicyBasic256,
119 'examples/certificate-example.der',
120 'examples/private-key-example.pem',
122 ua.MessageSecurityMode.None_
def test_nocrypto_feil(self)
def test_basic256_encrypt_success(self)
def test_basic256_encrypt_feil(self)
def test_basic128Rsa15_encrypt(self)
def test_basic256_encrypt(self)
def test_basic128Rsa15(self)