Ejemplo n.º 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).')
Ejemplo n.º 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).')
Ejemplo n.º 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).')
Ejemplo n.º 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").')
Ejemplo n.º 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").')
Ejemplo n.º 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).')
Ejemplo n.º 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").')
Ejemplo n.º 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").')
Ejemplo n.º 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',
     })
Ejemplo n.º 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',
     })