Beispiel #1
0
	def test_validateMessage_whenNoProjectInMessage(self) :
		s = SignatureValidator()
		with self.assertRaises(SignatureValidator.SignatureError) as cm:
			s.validateClientMessage(client='client1')
		self.assertEqual(
			"Project not specified in message"
			, cm.exception.message)
Beispiel #2
0
 def test_validateMessage_whenNoClientInMessage(self):
     s = SignatureValidator()
     with self.assertRaises(SignatureValidator.SignatureError) as cm:
         s.validateClientMessage(
             project='project1',
             boo='lalala',
         )
     self.assertEqual("Client not specified in message",
                      cm.exception.message)
Beispiel #3
0
 def test_validateMessage_whenBadClient(self):
     s = SignatureValidator()
     with self.assertRaises(SignatureValidator.SignatureError) as cm:
         s.validateClientMessage(
             project="project1",
             client="badclient",
         )
     self.assertEqual("Project or client not registered in server",
                      cm.exception.message)
Beispiel #4
0
	def test_validateMessage_whenBadClient(self) :
		s = SignatureValidator()
		with self.assertRaises(SignatureValidator.SignatureError) as cm:
			s.validateClientMessage(
				project="project1",
				client="badclient",
				)
		self.assertEqual(
			"Project or client not registered in server"
			, cm.exception.message)
Beispiel #5
0
	def test_validateMessage_whenNoClientInMessage(self) :
		s = SignatureValidator()
		with self.assertRaises(SignatureValidator.SignatureError) as cm:
			s.validateClientMessage(
				project='project1',
				boo='lalala',
				)
		self.assertEqual(
			"Client not specified in message"
			, cm.exception.message)
Beispiel #6
0
	def test_addClientKey(self) :
		s = SignatureValidator(FSClientKeyRing("fixture"))
		s.addClient(
			"project1","client1",
			publicKey = self.publicKey,
			)
		self.assertEqual([
			("project1","client1"),
			], s.clients())
		self.assertEqual(
			self.publicKey,
			s.clientKey(("project1","client1")),
		)
Beispiel #7
0
 def test_validateMessage_whenGoodSignature(self):
     s = SignatureValidator()
     s.addClient(
         project="project1",
         client="client1",
         publicKey=self.publicKey,
     )
     message = dict(
         project="project1",
         client="client1",
     )
     result = s.validateClientMessage(**self.signed(**message))
     self.assertEqual(True, result)
Beispiel #8
0
	def test_validateMessage_whenGoodSignature(self) :
		s = SignatureValidator()
		s.addClient(
			project = "project1",
			client="client1",
			publicKey = self.publicKey,
			)
		message = dict(
			project = "project1",
			client="client1",
			)
		result = s.validateClientMessage(**self.signed(**message))
		self.assertEqual(
			True
			, result)
Beispiel #9
0
	def test_validateMessage_whenNoSignature(self) :
		s = SignatureValidator()
		s.addClient(
			project = "project1",
			client="client1",
			publicKey = self.publicKey,
			)
		with self.assertRaises(SignatureValidator.SignatureError) as cm:
			s.validateClientMessage(
				project = "project1",
				client="client1",
				)
		self.assertEqual(
			"Message not signed"
			, cm.exception.message)
Beispiel #10
0
 def test_validateMessage_afterSettingWithTheSameValue(self):
     s = SignatureValidator()
     s.addClient(
         project="project1",
         client="client1",
         publicKey=self.publicKey,
     )
     message = dict(
         project="project1",
         client="client1",
     )
     signed = self.signed(**message)
     signed['client'] = "client1"
     result = s.validateClientMessage(**signed)
     self.assertEqual(True, result)
Beispiel #11
0
	def test_validateMessage_afterSettingWithTheSameValue(self) :
		s = SignatureValidator()
		s.addClient(
			project = "project1",
			client="client1",
			publicKey = self.publicKey,
			)
		message = dict(
			project = "project1",
			client="client1",
			)
		signed = self.signed(**message)
		signed['client'] = "client1"
		result = s.validateClientMessage(**signed)
		self.assertEqual(
			True
			, result)
Beispiel #12
0
	def test_validateMessage_whenBadSignature(self) :
		s = SignatureValidator()
		s.addClient(
			project = "project1",
			client="client1",
			publicKey = self.publicKey,
			)
		message = dict(
			project = "project1",
			client="client1",
			signature = [1L,2L,3L,4L],
			)
		with self.assertRaises(SignatureValidator.SignatureError) as cm:
			s.validateClientMessage(**message)
		self.assertEqual(
			"Invalid signature"
			, cm.exception.message)
Beispiel #13
0
	def test_validateMessage_afterModified(self) :
		s = SignatureValidator()
		s.addClient(
			"project1","client1",
			publicKey = self.publicKey,
			)
		message = dict(
			project = "project1",
			client="client1",
			)
		signed = self.signed(**message)
		signed['new key'] = "different value"
		with self.assertRaises(SignatureValidator.SignatureError) as cm:
			s.validateClientMessage(**signed)
		self.assertEqual(
			"Invalid signature"
			, cm.exception.message)
Beispiel #14
0
 def test_validateMessage_whenNoSignature(self):
     s = SignatureValidator()
     s.addClient(
         project="project1",
         client="client1",
         publicKey=self.publicKey,
     )
     with self.assertRaises(SignatureValidator.SignatureError) as cm:
         s.validateClientMessage(
             project="project1",
             client="client1",
         )
     self.assertEqual("Message not signed", cm.exception.message)
Beispiel #15
0
 def test_addClientKey(self):
     s = SignatureValidator(FSClientKeyRing("fixture"))
     s.addClient(
         "project1",
         "client1",
         publicKey=self.publicKey,
     )
     self.assertEqual([
         ("project1", "client1"),
     ], s.clients())
     self.assertEqual(
         self.publicKey,
         s.clientKey(("project1", "client1")),
     )
Beispiel #16
0
 def test_validateMessage_whenBadSignature(self):
     s = SignatureValidator()
     s.addClient(
         project="project1",
         client="client1",
         publicKey=self.publicKey,
     )
     message = dict(
         project="project1",
         client="client1",
         signature=[1L, 2L, 3L, 4L],
     )
     with self.assertRaises(SignatureValidator.SignatureError) as cm:
         s.validateClientMessage(**message)
     self.assertEqual("Invalid signature", cm.exception.message)
Beispiel #17
0
 def test_validateMessage_afterModified(self):
     s = SignatureValidator()
     s.addClient(
         "project1",
         "client1",
         publicKey=self.publicKey,
     )
     message = dict(
         project="project1",
         client="client1",
     )
     signed = self.signed(**message)
     signed['new key'] = "different value"
     with self.assertRaises(SignatureValidator.SignatureError) as cm:
         s.validateClientMessage(**signed)
     self.assertEqual("Invalid signature", cm.exception.message)
Beispiel #18
0
 def test_validateMessage_whenNoProjectInMessage(self):
     s = SignatureValidator()
     with self.assertRaises(SignatureValidator.SignatureError) as cm:
         s.validateClientMessage(client='client1')
     self.assertEqual("Project not specified in message",
                      cm.exception.message)
Beispiel #19
0
 def test_default_noClient(self):
     s = SignatureValidator()
     self.assertEqual([], s.clients())
Beispiel #20
0
	def test_default_noClient(self) :
		s = SignatureValidator()
		self.assertEqual(
			[]
			, s.clients())