예제 #1
0
 def test_invalid_missing_id_and_key(self):
     data = {
         'other': 'data',
     }
     with self.assertRaises(InvalidRequest) as ctx:
         authenticate(data)
     self.assertEqual(str(ctx.exception),
                      'Authentication failed (missing "unit_id" field).')
예제 #2
0
 def test_invalid_missing_id_and_key(self):
     data = {
         'other': 'data',
     }
     with self.assertRaises(InvalidRequest) as ctx:
         authenticate(data)
     self.assertEqual(str(ctx.exception),
         'Authentication failed (missing "unit_id" field).')
예제 #3
0
 def test_disabled_unit(self):
     data = {
         'unit_id': 456,
         'secret_key': self.disabled_unit_key,
         'other': 'data',
     }
     with self.assertRaises(InvalidRequest) as ctx:
         authenticate(data)
     self.assertEqual(str(ctx.exception),
         'Authentication failed (unit is disabled).')
예제 #4
0
 def test_invalid_id(self):
     data = {
         'unit_id': 1234,
         'secret_key': self.secret_key,
         'other': 'data',
     }
     with self.assertRaises(InvalidRequest) as ctx:
         authenticate(data)
     self.assertEqual(str(ctx.exception),
         'Authentication failed (wrong "unit_id" and/or "secret_key").')
예제 #5
0
 def test_invalid_unit_id_format(self):
     data = {
         'unit_id': 'asdf',
         'secret_key': self.disabled_unit_key,
         'other': 'data',
     }
     with self.assertRaises(InvalidRequest) as ctx:
         authenticate(data)
     self.assertEqual(str(ctx.exception), 'Authentication failed '
         '("unit_id" should be an integer, not "asdf").')
예제 #6
0
 def test_disabled_unit(self):
     data = {
         'unit_id': 456,
         'secret_key': self.disabled_unit_key,
         'other': 'data',
     }
     with self.assertRaises(InvalidRequest) as ctx:
         authenticate(data)
     self.assertEqual(str(ctx.exception),
                      'Authentication failed (unit is disabled).')
예제 #7
0
 def test_invalid_id(self):
     data = {
         'unit_id': 1234,
         'secret_key': self.secret_key,
         'other': 'data',
     }
     with self.assertRaises(InvalidRequest) as ctx:
         authenticate(data)
     self.assertEqual(
         str(ctx.exception),
         'Authentication failed (wrong "unit_id" and/or "secret_key").')
예제 #8
0
 def test_invalid_unit_id_format(self):
     data = {
         'unit_id': 'asdf',
         'secret_key': self.disabled_unit_key,
         'other': 'data',
     }
     with self.assertRaises(InvalidRequest) as ctx:
         authenticate(data)
     self.assertEqual(
         str(ctx.exception), 'Authentication failed '
         '("unit_id" should be an integer, not "asdf").')
예제 #9
0
 def test_valid(self):
     data = {
         'unit_id': 123,
         'secret_key': self.secret_key,
         'other': 'data',
     }
     self.assertEqual(authenticate(data), {
         'unit_id': 123,
         'other': 'data',
     })
예제 #10
0
 def test_valid(self):
     data = {
         'unit_id': 123,
         'secret_key': self.secret_key,
         'other': 'data',
     }
     self.assertEqual(authenticate(data), {
         'unit_id': 123,
         'other': 'data',
     })