def test_rsa(self): email = "*****@*****.**" m = FileAccessMixin() privkey = m.read_file('vaultier.key') pubkey = m.read_file('vaultier.pub') signature = Authenticator.sign(privkey, email, 1) assert Authenticator.verify(pubkey, email, 1, signature) is True assert Authenticator.verify(pubkey, 'Unsigned text', 1, signature) is not True
def user2(db): m = FileAccessMixin() user = { "nickname": "blade", "email": "*****@*****.**", "public_key": m.read_file('vaultier.pub'), } return User.objects.create(**user)
def register_api_call(*args, **kwargs): m = FileAccessMixin() pubkey = m.read_file('vaultier.pub') kwargs['public_key'] = pubkey url = reverse('user-list') client = APIClient() response = client.post(url, kwargs) return response
def auth_api_call(email=None, date=None, signature=None): url = reverse('auth-auth') client = APIClient() m = FileAccessMixin() if not date: date = timezone.now() if not signature: privkey = m.read_file('vaultier.key') signature = Authenticator.sign(privkey, email, date) response = client.post( url, {'email': email, 'date': date, 'signature': signature}) return response
def privkey(): m = FileAccessMixin() return m.read_file('vaultier.key')
def pubkey(): m = FileAccessMixin() return m.read_file('vaultier.pub')