Beispiel #1
0
def testValidateSignedResource():
    resource = '{"1":"test"}'
    vk, sk = ecdsa.generate64uKeys()
    signature = ecdsa.signResource64u(resource, sk)

    # returns parsed json if signature is valid
    parsedResource = ecdsa.validateSignedResource(signature, resource, vk)

    assert parsedResource == json.loads(resource)
Beispiel #2
0
def testValidateSignedResourceInvalidSignature():
    resource = '{"1":"test"}'
    vk, sk = ecdsa.generate64uKeys()
    signature = ecdsa.signResource64u(resource, sk)

    with pytest.raises(didering.ValidationError) as ex:
        ecdsa.validateSignedResource(signature, '{"1":"tes"}', vk)

        assert ex.value == "Unverifiable signature"
Beispiel #3
0
def testSignResource64u():
    resource = "message"
    vk, sk = ecdsa.generate64uKeys()

    signature = ecdsa.signResource64u(resource, sk)

    assert str(signature) == signature
    assert len(signature) == 88
    assert len(str64uToBytes(signature)) == 64
Beispiel #4
0
def testValidateSignedResourceInvalidJson():
    resource = "message"
    vk, sk = ecdsa.generate64uKeys()
    signature = ecdsa.signResource64u(resource, sk)

    with pytest.raises(didering.ValidationError) as ex:
        ecdsa.validateSignedResource(signature, resource, vk)

        assert ex.value == "Invalid JSON"
Beispiel #5
0
def testGenerate64uKeys():
    vk, sk = ecdsa.generate64uKeys()

    assert len(vk) == 88
    assert len(sk) == 44

    # check that keys are strings
    assert str(vk) == vk
    assert str(sk) == sk