From 78c70337b071a5c71f3741963911566b57a19eb7 Mon Sep 17 00:00:00 2001 From: Yordan Kinkov <yordan.kinkov@vereign.com> Date: Sun, 24 Jul 2022 16:52:19 +0300 Subject: [PATCH] Update GetloginProofResult function according to changes in OCM client --- internal/regofunc/ocm.go | 9 ++++++++- internal/regofunc/ocm_test.go | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/internal/regofunc/ocm.go b/internal/regofunc/ocm.go index 0145bac5..b32f9922 100644 --- a/internal/regofunc/ocm.go +++ b/internal/regofunc/ocm.go @@ -74,8 +74,15 @@ func (of *OcmFuncs) GetLoginProofResult() (*rego.Function, rego.Builtin1) { return nil, err } + claims := map[string]interface{}{} + for _, cred := range res.Data.Data { + for cName, cValue := range cred.Claims { + claims[cName] = cValue + } + } + var val ast.Value - val, err = ast.InterfaceToValue(res.Data.Claims) + val, err = ast.InterfaceToValue(claims) if err != nil { return nil, err } diff --git a/internal/regofunc/ocm_test.go b/internal/regofunc/ocm_test.go index 63d022e5..26de0b04 100644 --- a/internal/regofunc/ocm_test.go +++ b/internal/regofunc/ocm_test.go @@ -70,12 +70,20 @@ func TestGetLoginProofResult(t *testing.T) { expected := `{"family_name":"Doe","name":"John"}` ocmResponse := `{ "statusCode": 200, - "message": "Proof presentation fetch successfully", "data": { - "credentialSubject": { - "name":"John", - "family_name":"Doe" - } + "state": "done", + "data": [ + { + "credentialSubject": { + "family_name":"Doe" + } + }, + { + "credentialSubject": { + "name":"John" + } + } + ] } }` -- GitLab