Skip to content

Commit

Permalink
fix: Update profile issuer id to be not mandatory
Browse files Browse the repository at this point in the history
closes trustbloc#594

Signed-off-by: talwinder50 <[email protected]>
  • Loading branch information
talwinder50 committed Jan 31, 2022
1 parent de984ef commit 7b22470
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
4 changes: 0 additions & 4 deletions pkg/profile/issuer/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ func validateProfileRequest(pr *ProfileData) error {
return fmt.Errorf("supported vc contexts mandatory")
}

if pr.SupportsWACI && pr.IssuerID == "" {
return fmt.Errorf("issuer id mandatory for waci profiles")
}

if !adapterutil.ValidHTTPURL(pr.URL) {
return fmt.Errorf("issuer url is invalid")
}
Expand Down
5 changes: 0 additions & 5 deletions pkg/profile/issuer/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ func TestCredentialRecord_SaveProfile(t *testing.T) {
err = record.SaveProfile(value)
require.Error(t, err)
require.Contains(t, err.Error(), "issuer url is invalid")

value.SupportsWACI = true
err = record.SaveProfile(value)
require.Error(t, err)
require.Contains(t, err.Error(), "issuer id mandatory for waci profiles")
})

t.Run("test save profile - profile already exists", func(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/restapi/issuer/operation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,10 @@ func mapProfileReqToData(data *ProfileDataRequest, didDoc *did.Doc) (*issuer.Pro
}
}

if data.SupportsWACI && data.IssuerID == "" {
data.IssuerID = uuid.New().String()
}

return &issuer.ProfileData{
ID: data.ID,
Name: data.Name,
Expand Down
3 changes: 2 additions & 1 deletion pkg/restapi/issuer/operation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ func TestCreateProfile(t *testing.T) {

vReq := createProfileData(uuid.New().String())
vReq.SupportsWACI = true
vReq.IssuerID = ""
vReq.CredentialScopes = []string{mockCredScope}
vReq.OIDCClientParams = &issuer.OIDCClientParams{
ClientID: "client id",
Expand Down Expand Up @@ -586,7 +587,7 @@ func TestCreateProfile(t *testing.T) {
require.Equal(t, vReq.URL, profileRes.URL)
require.Equal(t, vReq.SupportsAssuranceCredential, profileRes.SupportsAssuranceCredential)
require.Equal(t, vReq.CredentialScopes, profileRes.CredentialScopes)
require.Equal(t, vReq.IssuerID, profileRes.IssuerID)
require.NotNil(t, profileRes.IssuerID)
require.Equal(t, vReq.SupportsWACI, profileRes.SupportsWACI)
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/restapi/issuer/operation/support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func createProfileData(profileID string) *issuer.ProfileData {
URL: "http://issuer.example.com",
PresentationSigningKey: "did:example:123xyz#key-1",
SupportsWACI: false,
IssuerID: "did:example:123?linked-domains=3",
IssuerID: uuid.New().String(),
}
}

Expand Down

0 comments on commit 7b22470

Please sign in to comment.