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

[OSE-301] Implement Create, Get, List, Delete endpoints for issuance templates #231

Merged
merged 8 commits into from
Jan 3, 2023

Conversation

andresuribe87
Copy link
Contributor

Overview

This PR implements Create, Get, List, Delete endpoints for issuance templates.

Description

This is very similar to the existing CRUD endpoints. The only main difference is that there are validation checks for some of the fields including the schema, ID and expiry of all the IssuanceTemplate.Credentials objects.

How Has This Been Tested?

Added tests for each of the endpoints.

Checklist

Before submitting this PR, please make sure:

  • I have read the CONTRIBUTING document.
  • My code is consistent with the rest of the project
  • I have tagged the relevant reviewers and/or interested parties
  • I have updated the READMEs and other documentation of affected packages

References

SIP5

@codecov-commenter
Copy link

Codecov Report

Merging #231 (9170423) into main (f591c33) will decrease coverage by 0.38%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #231      +/-   ##
==========================================
- Coverage   23.33%   22.95%   -0.39%     
==========================================
  Files          27       27              
  Lines        2507     2549      +42     
==========================================
  Hits          585      585              
- Misses       1821     1863      +42     
  Partials      101      101              
Impacted Files Coverage Δ
pkg/server/router/issuance.go 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

}

type CreateIssuanceTemplateRequest struct {
issuing.IssuanceTemplate
}

func (r CreateIssuanceTemplateRequest) ToServiceRequest() *issuing.CreateIssuanceTemplateRequest {
return &issuing.CreateIssuanceTemplateRequest{
ID: uuid.NewString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

In our other objects (like schema) we don't have the UUID in the request and we create it on more layer down in the CreateSchema function which is closer to DB.

Shouldn't matter either way, but eventally we should be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point. Moved this to the service layer.


if err != nil {
return framework.NewRequestError(
util.LoggingErrorMsg(err, "could not get manifests"), 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.

"could not get templates"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

id := framework.GetParam(ctx, IDParam)
if id == nil {
return framework.NewRequestError(
util.LoggingNewError("cannot delete a presentation without an ID parameter"), 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.

template instead of presentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


if err := ir.service.DeleteIssuanceTemplate(&issuing.DeleteIssuanceTemplateRequest{ID: *id}); err != nil {
return framework.NewRequestError(
util.LoggingErrorMsgf(err, "could not delete presentation with id: %s", *id), http.StatusInternalServerError)
Copy link
Contributor

Choose a reason for hiding this comment

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

template instead of presentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@nitro-neal nitro-neal left a comment

Choose a reason for hiding this comment

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

Looks good, some minor comments

@andresuribe87 andresuribe87 merged commit e1c3b4c into TBD54566975:main Jan 3, 2023
Credentials: []issuing.CredentialTemplate{
{
ID: "output_descriptor_1",
Schema: "",
Copy link
Member

Choose a reason for hiding this comment

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

remove

Issuer: issuerResp.DID.ID,
Credentials: []issuing.CredentialTemplate{
{
ID: "",
Copy link
Member

Choose a reason for hiding this comment

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

set or remove

// The template to create.
IssuanceTemplate IssuanceTemplate `json:"issuanceTemplate"`
}

func (r CreateIssuanceTemplateRequest) IsValid() bool {
return util.IsValidStruct(r) == nil
Copy link
Member

Choose a reason for hiding this comment

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

why use this here and Validate() below - should they be consistent?

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

Successfully merging this pull request may close these issues.

4 participants