Skip to content

Commit

Permalink
Add test for missing attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
btimby committed May 4, 2018
1 parent 5128b27 commit f7a3fe1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,33 @@ def _reply_to_client():
try:
r.authenticate('username', 'password')
except radius.ChallengeResponse as e:
self.assertEqual(1, len(e.messages))
self.assertEqual([b'Message one'], e.messages)
self.assertEqual(b'Indiana', e.state)
self.assertEqual(128, e.prompt)
else:
self.fail('ChallengeResponse not raised')

def test_challenge_empty(self):
"""Test sending a message and receiving an challenge reply."""
def _reply_to_client():
"""Thread to act as server."""
data, addr = self.sock.recvfrom(radius.PACKET_MAX)
m1 = radius.Message.unpack(TEST_SECRET, data)
m2 = create_reply(m1, radius.CODE_ACCESS_CHALLENGE)
self.sock.sendto(m2.pack(), addr)

self.startServer(_reply_to_client)

r = radius.Radius(TEST_SECRET, host='localhost', port=self.port)
try:
r.authenticate('username', 'password')
except radius.ChallengeResponse as e:
self.assertEqual([], e.messages)
self.assertIsNone(e.state)
self.assertIsNone(e.prompt)
else:
self.fail('ChallengeResponse not raised')


class RadcryptTestCase(unittest.TestCase):
"""
Expand Down

0 comments on commit f7a3fe1

Please sign in to comment.