コード例 #1
0
 def test_password_after_expiration(self):
     password = '******'
     key = snappass.set_password(password, 1)
     time.sleep(1.5)
     # Expire functionality must be explicitly invoked using do_expire(time).
     # mockredis does not support automatic expiration at this time
     snappass.redis_client.do_expire()
     self.assertIsNone(snappass.get_password(key))
コード例 #2
0
ファイル: tests.py プロジェクト: pinterest/snappass
 def test_password_after_expiration(self):
     password = '******'
     key = snappass.set_password(password, 1)
     time.sleep(1.5)
     # Expire functionality must be explicitly invoked using do_expire(time).
     # mockredis does not support automatic expiration at this time
     snappass.redis_client.do_expire()
     self.assertIsNone(snappass.get_password(key))
コード例 #3
0
    def test_set_password(self):
        with freeze_time("2020-05-08 12:00:00") as frozen_time:
            password = '******'
            rv = self.app.post('/',
                               data={
                                   'password': password,
                                   'ttl': 'two weeks'
                               })

            html_content = rv.data.decode("ascii")
            key = re.search(
                r'id="password-link" value="https://localhost/([^"]+)',
                html_content).group(1)
            key = unquote(key)

            frozen_time.move_to("2020-05-22 11:59:59")
            self.assertEqual(snappass.get_password(key), password)

            frozen_time.move_to("2020-05-22 12:00:00")
            self.assertIsNone(snappass.get_password(key))
コード例 #4
0
ファイル: tests.py プロジェクト: Majed6/snappass
    def test_set_password_json(self):
        with freeze_time("2020-05-08 12:00:00") as frozen_time:
            password = '******'
            rv = self.app.post('/',
                               headers={'Accept': 'application/json'},
                               data={
                                   'password': password,
                                   'ttl': 'two weeks'
                               })

            json_content = rv.get_json()
            key = re.search(r'https://localhost/([^"]+)',
                            json_content['link']).group(1)
            key = unquote(key)

            frozen_time.move_to("2020-05-22 11:59:59")
            self.assertEqual(snappass.get_password(key), password)

            frozen_time.move_to("2020-05-22 12:00:00")
            self.assertIsNone(snappass.get_password(key))
コード例 #5
0
 def test_password_after_expiration(self):
     password = '******'
     key = snappass.set_password(password, 1)
     time.sleep(1.5)
     self.assertEqual(None, snappass.get_password(key))
コード例 #6
0
 def test_password_before_expiration(self):
     password = '******'
     key = snappass.set_password(password, 1)
     self.assertEqual(password, snappass.get_password(key))
コード例 #7
0
 def test_password_is_decoded(self):
     password = "******"
     key = snappass.set_password(password, 30)
     self.assertFalse(isinstance(snappass.get_password(key), bytes))
コード例 #8
0
 def test_get_password(self):
     password = "******"
     key = snappass.set_password(password, 30)
     self.assertEqual(password, snappass.get_password(key))
     # Assert that we can't look this up a second time.
     self.assertEqual(None, snappass.get_password(key))
コード例 #9
0
 def test_unencrypted_passwords_still_work(self):
     unencrypted_password = "******"
     storage_key = uuid.uuid4().hex
     snappass.redis_client.setex(storage_key, 30, unencrypted_password)
     retrieved_password = snappass.get_password(storage_key)
     self.assertEqual(unencrypted_password, retrieved_password)
コード例 #10
0
ファイル: tests.py プロジェクト: WilliamRen/snappass
 def test_get_password(self):
     password = "******"
     key = snappass.set_password(password, 30)
     self.assertEqual(password, snappass.get_password(key))
     # Assert that we can't look this up a second time.
     self.assertEqual(None, snappass.get_password(key))
コード例 #11
0
ファイル: tests.py プロジェクト: jameswthorne/snappass
 def test_password_after_expiration(self):
     password = '******'
     key = snappass.set_password(password, 1)
     time.sleep(1.5)
     self.assertEqual(None, snappass.get_password(key))
コード例 #12
0
ファイル: tests.py プロジェクト: jameswthorne/snappass
 def test_password_before_expiration(self):
     password = '******'
     key = snappass.set_password(password, 1)
     self.assertEqual(password, snappass.get_password(key))
コード例 #13
0
ファイル: tests.py プロジェクト: jameswthorne/snappass
 def test_password_is_decoded(self):
     password = "******"
     key = snappass.set_password(password, 30)
     self.assertFalse(isinstance(snappass.get_password(key), bytes))
コード例 #14
0
ファイル: tests.py プロジェクト: pinterest/snappass
 def test_unencrypted_passwords_still_work(self):
     unencrypted_password = "******"
     storage_key = uuid.uuid4().hex
     snappass.redis_client.setex(storage_key, 30, unencrypted_password)
     retrieved_password = snappass.get_password(storage_key)
     self.assertEqual(unencrypted_password, retrieved_password)