Esempio n. 1
0
    def test_new(self):
        """When the user has no secret yet, gets a new secret.

        Asserts that the secret requests a sufficient number of bytes
        from urandom.

        """
        self.patch(os, "urandom", self._urandom)
        self.assertEqual(self.store.query(Secret).count(), 0)

        secret = Secret.forUser(self.user)
        self.assertEqual(secret.entropy, "sikrit")
        self.assertEqual(secret.user, self.user)
Esempio n. 2
0
    def test_new(self):
        """When the user has no secret yet, gets a new secret.

        Asserts that the secret requests a sufficient number of bytes
        from urandom.

        """
        self.patch(os, "urandom", self._urandom)
        self.assertEqual(self.store.query(Secret).count(), 0)

        secret = Secret.forUser(self.user)
        self.assertEqual(secret.entropy, "sikrit")
        self.assertEqual(secret.user, self.user)
Esempio n. 3
0
    def test_same(self):
        """When the user already has a secret, gets that secret.

        """
        secret = Secret(store=self.store, entropy="xyzzy", user=self.user)
        self.assertIdentical(Secret.forUser(self.user), secret)
Esempio n. 4
0
    def test_same(self):
        """When the user already has a secret, gets that secret.

        """
        secret = Secret(store=self.store, entropy="xyzzy", user=self.user)
        self.assertIdentical(Secret.forUser(self.user), secret)