Skip to content
Snippets Groups Projects
Commit 7e2b0f92 authored by Lyuben Penkovski's avatar Lyuben Penkovski
Browse files

Unit tests for regofunc for issuer DID

parent 0ce1f19f
No related branches found
No related tags found
1 merge request!29Rego extension function to retrieve organization DID (issuer of proofs)
Pipeline #52133 passed with stages
in 1 minute and 13 seconds
......@@ -75,3 +75,24 @@ func TestGetAllKeysFunc(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, expected, string(resultBytes))
}
func TestIssuerDID(t *testing.T) {
expected := `{"did":"did:web:123"}`
signerSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprint(w, expected)
}))
defer signerSrv.Close()
keysFuncs := regofunc.NewPubkeyFuncs(signerSrv.URL, http.DefaultClient)
r := rego.New(
rego.Query(`issuer()`),
rego.FunctionDyn(keysFuncs.IssuerDID()),
rego.StrictBuiltinErrors(true),
)
resultSet, err := r.Eval(context.Background())
assert.NoError(t, err)
resultBytes, err := json.Marshal(resultSet[0].Expressions[0].Value)
assert.NoError(t, err)
assert.Equal(t, expected, string(resultBytes))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment