Esempio n. 1
0
 def test_mkSplit(self):
     t = 42
     nonce_str = mkNonce(t)
     self.assertTrue(nonce_re.match(nonce_str))
     et, salt = splitNonce(nonce_str)
     self.assertEqual(len(salt), 6)
     self.assertEqual(et, t)
Esempio n. 2
0
 def test_splitNonce(self):
     s = '1970-01-01T00:00:00Z'
     expected_t = 0
     expected_salt = ''
     actual_t, actual_salt = splitNonce(s)
     self.assertEqual(expected_t, actual_t)
     self.assertEqual(expected_salt, actual_salt)
Esempio n. 3
0
 def test_mkSplit(self):
     t = 42
     nonce_str = mkNonce(t)
     self.failUnless(nonce_re.match(nonce_str))
     et, salt = splitNonce(nonce_str)
     self.failUnlessEqual(len(salt), 6)
     self.failUnlessEqual(et, t)
Esempio n. 4
0
 def test_mkSplit(self):
     t = 42
     nonce_str = mkNonce(t)
     self.failUnless(nonce_re.match(nonce_str))
     et, salt = splitNonce(nonce_str)
     self.failUnlessEqual(len(salt), 6)
     self.failUnlessEqual(et, t)
Esempio n. 5
0
    def test_badNonce(self):
        """remove the nonce from the store

        From "Checking the Nonce"::

            When the Relying Party checks the signature on an assertion, the

            Relying Party SHOULD ensure that an assertion has not yet
            been accepted with the same value for "openid.response_nonce"
            from the same OP Endpoint URL.
        """
        nonce = mkNonce()
        stamp, salt = splitNonce(nonce)
        self.store.useNonce(self.server_url, stamp, salt)
        self.response = Message.fromOpenIDArgs(
                                  {'response_nonce': nonce,
                                   'ns':OPENID2_NS,
                                   })
        self.failUnlessRaises(ProtocolError, self.consumer._idResCheckNonce,
                              self.response, self.endpoint)