~stuartmetcalfe/django-openid-auth/staff-assignment

« back to all changes in this revision

Viewing changes to django_openid_auth/tests/test_store.py

  • Committer: James Henstridge
  • Date: 2009-05-27 14:36:23 UTC
  • Revision ID: james@jamesh.id.au-20090527143623-i6o50d69grs8psrb
Make changes to store implementation in response to the review of the 
Storm based OpenID store I wrote based on this one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        self.assertEquals(dbassoc.lifetime, 600)
57
57
        self.assertEquals(dbassoc.assoc_type, 'HMAC-SHA1')
58
58
 
 
59
    def test_storeAssociation_update_existing(self):
 
60
        assoc = OIDAssociation('handle', 'secret', 42, 600, 'HMAC-SHA1')
 
61
        self.store.storeAssociation('server-url', assoc)
 
62
 
 
63
        # Now update the association with new information.
 
64
        assoc = OIDAssociation('handle', 'secret2', 420, 900, 'HMAC-SHA256')
 
65
        self.store.storeAssociation('server-url', assoc)
 
66
        dbassoc = Association.objects.get(
 
67
            server_url='server-url', handle='handle')
 
68
        self.assertEqual(dbassoc.secret, 'secret2'.encode('base-64'))
 
69
        self.assertEqual(dbassoc.issued, 420)
 
70
        self.assertEqual(dbassoc.lifetime, 900)
 
71
        self.assertEqual(dbassoc.assoc_type, 'HMAC-SHA256')
 
72
 
59
73
    def test_getAssociation(self):
60
74
        timestamp = int(time.time())
61
75
        self.store.storeAssociation(
104
118
        self.assertEquals(assoc.issued, timestamp + 1)
105
119
 
106
120
    def test_removeAssociation(self):
107
 
        self.assertEquals(
108
 
            self.store.removeAssociation('server-url', 'unknown'), False)
109
 
 
110
121
        timestamp = int(time.time())
111
122
        self.store.storeAssociation(
112
123
            'server-url', OIDAssociation('handle', 'secret', timestamp, 600,
116
127
        self.assertEquals(
117
128
            self.store.getAssociation('server-url', 'handle'), None)
118
129
 
 
130
    def test_removeAssociation_unknown(self):
 
131
        self.assertEquals(
 
132
            self.store.removeAssociation('server-url', 'unknown'), False)
 
133
 
119
134
    def test_useNonce(self):
120
135
        timestamp = time.time()
121
136
        # The nonce can only be used once.