Skip to content

Commit

Permalink
check buffer size for GSSAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
aholmberg committed Jan 27, 2016
1 parent 8045568 commit 4f87cdd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/unit/test_mechanism.py
Expand Up @@ -115,15 +115,17 @@ def test_process_qop(self, *args):
self.assertRaises(SASLProtocolException, self.sasl.process, msg)

max_len = 100
self.assertLess(max_len, self.sasl.max_buffer)
for i, qop in ((1, 'auth'), (2, 'auth-int'), (4, 'auth-conf')): # 1, 2, 4 --> qop flag
qop_size = struct.pack('!i', i << 24 | 100)
qop_size = struct.pack('!i', i << 24 | max_len)
response = base64.b64encode(qop_size)
with patch('puresasl.mechanisms.kerberos.authGSSClientResponse', return_value=response), \
patch('puresasl.mechanisms.kerberos.authGSSClientWrap') as authGSSClientWrap:
self.mechanism.complete = False
self.assertEqual(self.sasl.process(msg), qop_size)
self.assertTrue(self.mechanism.complete)
self.assertEqual(self.mechanism.qop, qop)
self.assertEqual(self.mechanism.max_buffer, max_len)

args = authGSSClientWrap.call_args[0]
out_data = args[1]
Expand Down

0 comments on commit 4f87cdd

Please sign in to comment.