Skip to content

Commit

Permalink
0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
akarneliuk committed Jul 2, 2022
1 parent f7b5da9 commit a7aafa3
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test_06_certificate_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ def test_ipv4_address_certificate_download():
assert "supported_models" in result
assert "supported_encodings" in result
assert "gnmi_version" in result

del gconn
38 changes: 38 additions & 0 deletions tests/test_07_authentication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Collection of unit tests to test various authentication methods
"""
# Modules
import os
from pygnmi.client import gNMIclient


# Statics
ENV_USERNAME = os.getenv("PYGNMI_USER")
ENV_PASSWORD = os.getenv("PYGNMI_PASS")
ENV_ADDRESS = os.getenv("PYGNMI_HOST")
ENV_HOSTNAME = os.getenv("PYGNMI_NAME")
ENV_PORT = os.getenv("PYGNMI_PORT")
ENV_PATH_CERT = os.getenv("PYGNMI_CERT")


# Tests
def test_authentication_token():
"""
Unit test to test authentication with token
"""
gconn = gNMIclient(target=(ENV_HOSTNAME, ENV_PORT),
username=ENV_USERNAME,
password=ENV_PASSWORD,
override=ENV_ADDRESS,
token="ABC")
gconn.connect()

result = gconn.capabilities()

gconn.close()

assert "supported_models" in result
assert "supported_encodings" in result
assert "gnmi_version" in result

del gconn
42 changes: 42 additions & 0 deletions tests/test_08_test_cipher_change.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Collection of unit tests to test change of cipher
"""
# Modules
import os
import grpc
from pygnmi.client import gNMIclient


# Statics
ENV_USERNAME = os.getenv("PYGNMI_USER")
ENV_PASSWORD = os.getenv("PYGNMI_PASS")
ENV_ADDRESS = os.getenv("PYGNMI_HOST")
ENV_HOSTNAME = os.getenv("PYGNMI_NAME")
ENV_PORT = os.getenv("PYGNMI_PORT_2")
ENV_PATH_CERT = os.getenv("PYGNMI_CERT")


# Tests
def test_authentication_token():
"""
Unit test to test authentication with token
"""
gconn = gNMIclient(target=(ENV_HOSTNAME, ENV_PORT),
username=ENV_USERNAME,
password=ENV_PASSWORD,
override=ENV_ADDRESS,
path_cert=ENV_PATH_CERT)

cipher_value_1 = None
cipher_value_2 = None

try:
cipher_value_1 = os.getenv("GRPC_SSL_CIPHER_SUITES")
gconn.connect()

except grpc.FutureTimeoutError:
cipher_value_2 = os.getenv("GRPC_SSL_CIPHER_SUITES")

assert cipher_value_1 != cipher_value_2

del gconn

0 comments on commit a7aafa3

Please sign in to comment.