Skip to content

Commit

Permalink
feat: credential issuance history: remove profile version from URL
Browse files Browse the repository at this point in the history
Signed-off-by: Mykhailo Sizov <[email protected]>
  • Loading branch information
mishasizov-SK committed Oct 16, 2023
1 parent 398b8a9 commit 93cdd39
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 177 deletions.
86 changes: 43 additions & 43 deletions api/spec/openapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions component/wallet-cli/cmd/oidc4vci_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ import (
"log/slog"
"net/http"
"net/http/cookiejar"
"strings"

"github.com/henvic/httpretty"
"github.com/piprate/json-gold/ld"
"github.com/samber/lo"
"github.com/spf13/cobra"
vdrapi "github.com/trustbloc/did-go/vdr/api"
storageapi "github.com/trustbloc/kms-go/spi/storage"
Expand Down Expand Up @@ -294,7 +292,6 @@ func NewOIDC4VCICommand() *cobra.Command {

slog.Info("credential added to wallet",
"credential_id", vc.Contents().ID,
"credential_type", strings.Join(lo.Filter(vc.Contents().Types, func(item string, i int) bool { return !strings.EqualFold(item, "VerifiableCredential") }), ","),
"issuer_id", vc.Contents().Issuer.ID,
)

Expand Down
8 changes: 1 addition & 7 deletions docs/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,14 @@ paths:
description: Returns openid-config.
tags:
- issuer
'/issuer/profiles/{profileID}/{profileVersion}/issued-credentials':
'/issuer/profiles/{profileID}/issued-credentials':
parameters:
- schema:
type: string
name: profileID
in: path
required: true
description: Profile ID
- schema:
type: string
name: profileVersion
in: path
required: true
description: Profile Version
get:
summary: Request Credential Issuance history.
responses:
Expand Down
7 changes: 3 additions & 4 deletions pkg/restapi/v1/issuer/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ type credentialIssuanceHistoryStore interface {
GetIssuedCredentialsMetadata(
ctx context.Context,
profileID string,
profileVersion string,
) ([]*credentialstatus.CredentialMetadata, error)
}

Expand Down Expand Up @@ -690,10 +689,10 @@ func (c *Controller) PrepareCredential(e echo.Context) error {
}

// CredentialIssuanceHistory returns Credential Issuance history.
// GET /issuer/profiles/{profileID}/{profileVersion}/issued-credentials.
func (c *Controller) CredentialIssuanceHistory(e echo.Context, profileID string, profileVersion string) error {
// GET /issuer/profiles/{profileID}/issued-credentials.
func (c *Controller) CredentialIssuanceHistory(e echo.Context, profileID string) error {
credentialMetadata, err := c.credentialIssuanceHistoryStore.
GetIssuedCredentialsMetadata(e.Request().Context(), profileID, profileVersion)
GetIssuedCredentialsMetadata(e.Request().Context(), profileID)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/restapi/v1/issuer/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ func TestCredentialIssuanceHistory(t *testing.T) {
}

credentialIssuanceStore.EXPECT().
GetIssuedCredentialsMetadata(gomock.Any(), profileID, profileVersion).
GetIssuedCredentialsMetadata(gomock.Any(), profileID).
Times(1).
Return([]*credentialstatus.CredentialMetadata{credentialMetadata}, nil)

Expand All @@ -1646,7 +1646,7 @@ func TestCredentialIssuanceHistory(t *testing.T) {

echoCtx := echoContext(withRecorder(recorder))

err := c.CredentialIssuanceHistory(echoCtx, profileID, profileVersion)
err := c.CredentialIssuanceHistory(echoCtx, profileID)
assert.NoError(t, err)

var gotResponse []CredentialIssuanceHistoryData
Expand All @@ -1669,7 +1669,7 @@ func TestCredentialIssuanceHistory(t *testing.T) {

t.Run("credentialIssuanceHistoryStore error", func(t *testing.T) {
credentialIssuanceStore.EXPECT().
GetIssuedCredentialsMetadata(gomock.Any(), profileID, profileVersion).
GetIssuedCredentialsMetadata(gomock.Any(), profileID).
Times(1).
Return(nil, errors.New("some error"))

Expand All @@ -1681,7 +1681,7 @@ func TestCredentialIssuanceHistory(t *testing.T) {

echoCtx := echoContext(withRecorder(recorder))

err := c.CredentialIssuanceHistory(echoCtx, profileID, profileVersion)
err := c.CredentialIssuanceHistory(echoCtx, profileID)
assert.Error(t, err)
})
}
Expand Down
Loading

0 comments on commit 93cdd39

Please sign in to comment.