Skip to content

Commit

Permalink
chore: Comment out signCredential
Browse files Browse the repository at this point in the history
closes #43

Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
  • Loading branch information
fqutishat committed Jan 29, 2020
1 parent 3a7cc4b commit de489dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 34 deletions.
1 change: 1 addition & 0 deletions cmd/vc-rest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hyperledger/aries-framework-go v0.1.1-0.20200121182508-01fa9ee94644 h1:BRYsh0ubFrsDYRdjQrl/i6baBy/jGEzGfUA70GT9bFc=
github.com/hyperledger/aries-framework-go v0.1.1-0.20200121182508-01fa9ee94644/go.mod h1:EWYMDfPqWVI/XxSvvCQJHJYEwYRWChhN7ItoM1SGinI=
github.com/hyperledger/aries-framework-go v0.1.1 h1:E9ZbE1ob3yvttio9K4xygjy0sUornEXGkO21m1r5Y+g=
github.com/hyperledger/aries-framework-go v0.1.1/go.mod h1:EWYMDfPqWVI/XxSvvCQJHJYEwYRWChhN7ItoM1SGinI=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down
12 changes: 0 additions & 12 deletions pkg/restapi/vc/operation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,6 @@ func (o *Operation) createCredentialHandler(rw http.ResponseWriter, req *http.Re
}

func (o *Operation) signCredential(profile *ProfileResponse, vc *verifiable.Credential) (*verifiable.Credential, error) { // nolint:lll
signingCtx := &verifiable.LinkedDataProofContext{
Creator: profile.Creator,
SignatureType: profile.SignatureType,
Suite: ed25519signature2018.New(),
PrivateKey: o.keySet.private,
}

err := vc.AddLinkedDataProof(signingCtx)
if err != nil {
return nil, err
}

return vc, nil
}

Expand Down
46 changes: 24 additions & 22 deletions pkg/restapi/vc/operation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,28 +214,30 @@ func TestCreateCredentialHandler(t *testing.T) {
})
}

func TestCreateCredentialHandler_SignatureError(t *testing.T) {
client := mock.NewMockEDVClient("test")
op, err := New(memstore.NewProvider(), client)
require.NoError(t, err)

err = op.profileStore.SaveProfile(getTestProfile())
require.NoError(t, err)

// clear private key
op.keySet.private = nil

createCredentialHandler := getHandler(t, op, createCredentialEndpoint)

req, err := http.NewRequest(http.MethodPost, createCredentialEndpoint,
bytes.NewBuffer([]byte(testCreateCredentialRequest)))
require.NoError(t, err)

rr := httptest.NewRecorder()
createCredentialHandler.Handle().ServeHTTP(rr, req)
require.Equal(t, http.StatusInternalServerError, rr.Code)
require.Contains(t, rr.Body.String(), "failed to sign credential")
}
// TODO re-enable it in 0.1.2

// func TestCreateCredentialHandler_SignatureError(t *testing.T) {
// client := mock.NewMockEDVClient("test")
// op, err := New(memstore.NewProvider(), client)
// require.NoError(t, err)
//
// err = op.profileStore.SaveProfile(getTestProfile())
// require.NoError(t, err)
//
// // clear private key
// op.keySet.private = nil
//
// createCredentialHandler := getHandler(t, op, createCredentialEndpoint)
//
// req, err := http.NewRequest(http.MethodPost, createCredentialEndpoint,
// bytes.NewBuffer([]byte(testCreateCredentialRequest)))
// require.NoError(t, err)
//
// rr := httptest.NewRecorder()
// createCredentialHandler.Handle().ServeHTTP(rr, req)
// require.Equal(t, http.StatusInternalServerError, rr.Code)
// require.Contains(t, rr.Body.String(), "failed to sign credential")
// }

func TestVerifyCredentialHandler(t *testing.T) {
client := mock.NewMockEDVClient("test")
Expand Down

0 comments on commit de489dc

Please sign in to comment.