Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
92ed5317
Commit
92ed5317
authored
Feb 18, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first crypto connection tests
parent
924bf379
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
3 deletions
+67
-3
tests/tests.py
tests/tests.py
+1
-0
tests/tests_client.py
tests/tests_client.py
+2
-3
tests/tests_crypto_connect.py
tests/tests_crypto_connect.py
+64
-0
No files found.
tests/tests.py
View file @
92ed5317
...
...
@@ -10,6 +10,7 @@ from tests_cmd_lines import TestCmdLines
from
tests_server
import
TestServer
from
tests_client
import
TestClient
from
tests_unit
import
Unit
from
tests_crypto_connect
import
TestCryptoConnect
if
__name__
==
'__main__'
:
...
...
tests/tests_client.py
View file @
92ed5317
...
...
@@ -13,9 +13,8 @@ class TestClient(unittest.TestCase, CommonTests):
'''
Run common tests on client side
Of course we need a server so we start a server in another
process using python Process module
Tests that can only be run on client side must be defined here
Of course we need a server so we start also start a server
Tests that can only be run on client side must be defined in this class
'''
@
classmethod
def
setUpClass
(
self
):
...
...
tests/tests_crypto_connect.py
0 → 100644
View file @
92ed5317
import
unittest
from
opcua
import
Client
from
opcua
import
Server
from
opcua
import
ua
port_num1
=
48515
port_num2
=
48512
class
TestCryptoConnect
(
unittest
.
TestCase
):
'''
Test connectino with a server supporting crypto
'''
@
classmethod
def
setUpClass
(
self
):
# start our own server
self
.
srv_crypto
=
Server
()
self
.
uri_crypto
=
'opc.tcp://localhost:%d'
%
port_num1
self
.
srv_crypto
.
set_endpoint
(
self
.
uri_crypto
)
# load server certificate and private key. This enables endpoints
# with signing and encryption.
self
.
srv_crypto
.
load_certificate
(
"examples/example-certificate.der"
)
self
.
srv_crypto
.
load_private_key
(
"examples/example-private-key.pem"
)
self
.
srv_crypto
.
start
()
# start a server without crypto
self
.
srv_no_crypto
=
Server
()
self
.
uri_no_crypto
=
'opc.tcp://localhost:%d'
%
port_num2
self
.
srv_no_crypto
.
set_endpoint
(
self
.
uri_no_crypto
)
self
.
srv_no_crypto
.
start
()
@
classmethod
def
tearDownClass
(
self
):
# stop the server
self
.
srv_no_crypto
.
stop
()
self
.
srv_crypto
.
stop
()
def
test_nocrypto
(
self
):
clt
=
Client
(
self
.
uri_no_crypto
)
clt
.
connect
()
try
:
clt
.
get_objects_node
().
get_children
()
finally
:
clt
.
disconnect
()
def
test_nocrypto_feil
(
self
):
clt
=
Client
(
self
.
uri_no_crypto
)
with
self
.
assertRaises
(
ua
.
UaError
):
clt
.
set_security_string
(
"Basic256,Sign,examples/example-certificate.der,examples/example-private-key.pem"
)
def
test_basic256
(
self
):
clt
=
Client
(
self
.
uri_crypto
)
try
:
clt
.
set_security_string
(
"Basic256,Sign,examples/example-certificate.der,examples/example-private-key.pem"
)
clt
.
connect
()
self
.
assertTrue
(
clt
.
get_objects_node
().
get_children
())
finally
:
clt
.
disconnect
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment