示例#1
0
    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
示例#2
0
def user2(db):
    m = FileAccessMixin()
    user = {
        "nickname": "blade",
        "email": "*****@*****.**",
        "public_key": m.read_file('vaultier.pub'),
    }
    return User.objects.create(**user)
示例#3
0
def user2(db):
    m = FileAccessMixin()
    user = {
        "nickname": "blade",
        "email": "*****@*****.**",
        "public_key": m.read_file('vaultier.pub'),
    }
    return User.objects.create(**user)
示例#4
0
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
示例#5
0
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
示例#6
0
def privkey():
    m = FileAccessMixin()
    return m.read_file('vaultier.key')
示例#7
0
def pubkey():
    m = FileAccessMixin()
    return m.read_file('vaultier.pub')
示例#8
0
def privkey():
    m = FileAccessMixin()
    return m.read_file('vaultier.key')
示例#9
0
def pubkey():
    m = FileAccessMixin()
    return m.read_file('vaultier.pub')