Skip to content

Commit 1bc264b

Browse files
Added unit tests
1 parent 0cd2684 commit 1bc264b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

SoftLayer/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class X509Authentication(AuthenticationBase):
143143
"""X509Authentication authentication class.
144144
145145
:param certificate str: Path to a users SSL certificate for authentication
146-
:param CA Cert str: Path to the CA bundle for softlayer hostnames.
146+
:param CA Cert str: Path to the Servers signed certificate.
147147
"""
148148

149149
def __init__(self, cert, ca_cert):
@@ -157,4 +157,4 @@ def get_request(self, request):
157157
return request
158158

159159
def __repr__(self):
160-
return f"X509Authentication(cert={cert}, ca_cert={ca_cert})"
160+
return f"X509Authentication(cert={self.cert}, ca_cert={self.ca_cert})"

tests/auth_tests.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,22 @@ def test_repr(self):
8383
s = repr(self.auth)
8484
self.assertIn('BasicHTTPAuthentication', s)
8585
self.assertIn('USERNAME', s)
86+
87+
88+
class TestX509AUthentication(testing.TestCase):
89+
def set_up(self):
90+
self.auth = auth.X509Authentication('authcert.pm', 'servercert.pm')
91+
92+
def test_attribs(self):
93+
self.assertEqual(self.auth.cert, 'authcert.pm')
94+
self.assertEqual(self.auth.ca_cert, 'servercert.pm')
95+
96+
def test_get_request(self):
97+
req = transports.Request()
98+
authed_req = self.auth.get_request(req)
99+
self.assertEqual(authed_req.cert, 'authcert.pm')
100+
self.assertEqual(authed_req.verify, 'servercert.pm')
101+
102+
def test_repr(self):
103+
s = repr(self.auth)
104+
self.assertEqual(s, "X509Authentication(cert=authcert.pm, ca_cert=servercert.pm)")

0 commit comments

Comments
 (0)