Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add create issue credential #6

Merged
merged 1 commit into from
Jan 15, 2020

Conversation

talwinder50
Copy link
Member

closes #2

Signed-off-by: talwinder.kaur talwinder.kaur@securekey.com

@cla-bot cla-bot bot added the cla-signed label Jan 11, 2020
@todo
Copy link

todo bot commented Jan 11, 2020

create the issuer profile and get the prefix of the ID from the profile issue-47

https://github.com/trustbloc/edge-service/blob/0cecb58ca8ffc2c1d41c27d2478ee15a2c09369e/pkg/restapi/issuer/operation/operations.go#L26-L31


This comment was generated by todo based on a TODO comment in 0cecb58 in #6. cc @talwinder50.

credential.Types = data.Type
credential.Issuer = data.Issuer
credential.Issued = &issueDate
credential.Schemas = []verifiable.TypedID{}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna remove this , as the bug was raised to dima and he fixed

time.Now().Hour(), time.Now().Minute(), time.Now().Second(), 0, time.UTC)

// todo Issue raised, only base context doesnt work
credential.Context = []string{credentialContext, data.Context}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna remove this , as the bug was raised to dima and he fixed

@codecov
Copy link

codecov bot commented Jan 13, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@b49615a). Click here to learn what that means.
The diff coverage is 94.59%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #6   +/-   ##
=========================================
  Coverage          ?   94.59%           
=========================================
  Files             ?        4           
  Lines             ?       74           
  Branches          ?        0           
=========================================
  Hits              ?       70           
  Misses            ?        2           
  Partials          ?        2
Impacted Files Coverage Δ
pkg/restapi/vc/controller.go 100% <100%> (ø)
pkg/internal/common/support/httphandler.go 100% <100%> (ø)
pkg/utils/cmd/util.go 81.81% <81.81%> (ø)
pkg/restapi/vc/operation/operations.go 95.83% <95.83%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b49615a...4ec9046. Read the comment docs.

cmd/issuer-rest/startcmd/start.go Outdated Show resolved Hide resolved
pkg/restapi/issuer/operation/operations.go Outdated Show resolved Hide resolved
@todo
Copy link

todo bot commented Jan 14, 2020

create the profile and get the prefix of the ID from the profile issue-47

https://github.com/trustbloc/edge-service/blob/dfcd8568792d9c368d95615b1e5eb002b8214452/pkg/restapi/vc/operation/operations.go#L26-L31


This comment was generated by todo based on a TODO comment in dfcd856 in #6. cc @talwinder50.

err := json.NewDecoder(req.Body).Decode(&data)

if err != nil {
rw.WriteHeader(http.StatusBadRequest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no return in this error block

cred, err := createCredential(&data)

if err != nil {
log.Errorf("Failed to create new credential: %s", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need error status and return here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should InternalServerError be used instead of StatusNotAcceptable? @sandrask what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this to StatusBadRequest


resp, err := json.Marshal(cred)
if err != nil {
log.Errorf("Failed to marshal credential: %s", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above: set error status and return here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


_, err = rw.Write(resp)
if err != nil {
log.Errorf("Failed to write response for VCInputData vault creation success: %s", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above: set error status and return here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - I missed this earlier when reviewing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


_, err = rw.Write(resp)
if err != nil {
log.Errorf("Failed to write response for VCInputData vault creation success: %s", err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - I missed this earlier when reviewing


createCredentialHandler.Handle().ServeHTTP(rr, req)

require.Equal(t, http.StatusBadRequest, rr.Code)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something else to check out...it looks like your handler will always return StatusCreated, so I'm curious why this test actually passes. (The subsequent call to WriteHeader is ignored?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

closes trustbloc#2

Signed-off-by: talwinder.kaur <talwinder.kaur@securekey.com>
validCredential, err := createCredential(&data)

if err != nil {
rw.WriteHeader(http.StatusNotAcceptable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why status not acceptable: it should be either bad request or internal server error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Credential Issuer Rest API
3 participants