-
Notifications
You must be signed in to change notification settings - Fork 53
Conversation
@@ -129,22 +129,26 @@ func newRequestContextWithParams(w http.ResponseWriter, req *http.Request, param | |||
return c | |||
} | |||
|
|||
func getValidManifestRequest(issuerDID, issuerKID, schemaID string) model.CreateManifestRequest { | |||
func getValidCreateManifestRequest(issuerDID, issuerKID, schemaID string) model.CreateManifestRequest { | |||
return model.CreateManifestRequest{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated this test to use real input/output descriptors for readability
pkg/service/credential/service.go
Outdated
if request.SchemaID != "" { | ||
// resolve schema and save it for validation later | ||
gotSchema, err := s.schema.GetSchema(ctx, schema.GetSchemaRequest{ID: request.SchemaID}) | ||
if err != nil { | ||
return nil, sdkutil.LoggingErrorMsgf(err, "failed to create credential; could not get schema: %s", request.SchemaID) | ||
} | ||
knownSchema = &gotSchema.Schema | ||
|
||
schemaType := schemalib.CredentialSchema2023Type | ||
if gotSchema.CredentialSchema == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now this branch will always be true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in other places, I think we should completely remove.
@@ -0,0 +1,97 @@ | |||
package credential |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved this to another file for readability
Codecov Report
@@ Coverage Diff @@
## main #494 +/- ##
==========================================
+ Coverage 20.57% 21.02% +0.44%
==========================================
Files 48 49 +1
Lines 5769 5803 +34
==========================================
+ Hits 1187 1220 +33
+ Misses 4373 4358 -15
- Partials 209 225 +16
|
BaseServiceConfig: new(BaseServiceConfig), | ||
} | ||
} | ||
services.DIDConfig.ServiceEndpoint = endpoint + "/dids" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone sets the service_endpoint
for a single service and not others, seems like this will override. Is that intentional? Should defaults be applied before decoding the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be refactored because we don't want to enable config for setting service endpoints. I'll open a new issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -155,6 +165,14 @@ func TestManifestRouter(t *testing.T) { | |||
ID: storage.StatusObjectID(createdApplicationResponseOp.ID), | |||
Approved: true, | |||
Reason: "ApprovalMan is here", | |||
CredentialOverrides: map[string]model.CredentialOverride{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this here? I.e. was there a test that was failing? Or was the test not exercising the desired behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the schema the test was using did not have any required fields - so it wasn't a great test. once I added them this is necessary
pkg/server/router/schema.go
Outdated
Name string `json:"name" validate:"required"` | ||
Description string `json:"description,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind adding godocs for these two fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
Schema schemalib.JSONSchema `json:"schema" validate:"required"` | ||
|
||
// TODO(gabe): re-enable in https://github.com/TBD54566975/ssi-service/issues/493 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand why this change requires disabling an already existing feature. Was it broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a slightly different feature, since before we weren't creating credentials just JWTs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not keep the verification endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since it will be a credential and we already have a credential verification endpoint
we could add a new endpoint to see whether a cred is valid against a schema - but that's a new ticket
pkg/service/schema/model.go
Outdated
Reason string `json:"reason,omitempty"` | ||
ID string `json:"id"` | ||
Schema schema.JSONSchema `json:"schema"` | ||
CredentialSchema *keyaccess.JWT `json:"credentialSchema,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be returned from the schema.Service
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
going to remove this and save it for the next issue
pkg/service/schema/model.go
Outdated
SchemaJWT *keyaccess.JWT `json:"schemaJwt,omitempty"` | ||
ID string `json:"id"` | ||
Schema schema.JSONSchema `json:"schema"` | ||
CredentialSchema *keyaccess.JWT `json:"credentialSchema,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. Suggestion is that schema.Service
only stores plain schemas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's take this in the next issue
} | ||
|
||
// TODO(gabe) support signing credential schemas | ||
// create schema | ||
storedSchema := StoredSchema{ID: schemaID, Schema: jsonSchema} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two IDs within a StoredSchema: id
and schema.$id
. I think it's easily confused. Would it make sense to only have one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason for two: when you view the schema on it's own you need a fully qualified URI to resolve it (e.g. tbd.website/schemas/01841408-1408140148
when you are talking to the service, it is awkward to request anything but 01841408-1408140148
so 01841408-1408140148
is the service identifier, whereas the $id
is the fully qualified identifier
pkg/service/schema/storage.go
Outdated
return nil, nil | ||
} | ||
var stored []StoredSchema | ||
for _, schemaBytes := range gotSchemas { | ||
var nextSchema StoredSchema | ||
if err := json.Unmarshal(schemaBytes, &nextSchema); err == nil { | ||
if err = json.Unmarshal(schemaBytes, &nextSchema); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invert the order to reduce nesting:
if err != nil {
// log here
continue
}
stored = append(stored, nextSchema)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/service/credential/service.go
Outdated
if request.SchemaID != "" { | ||
// resolve schema and save it for validation later | ||
gotSchema, err := s.schema.GetSchema(ctx, schema.GetSchemaRequest{ID: request.SchemaID}) | ||
if err != nil { | ||
return nil, sdkutil.LoggingErrorMsgf(err, "failed to create credential; could not get schema: %s", request.SchemaID) | ||
} | ||
knownSchema = &gotSchema.Schema | ||
|
||
schemaType := schemalib.CredentialSchema2023Type | ||
if gotSchema.CredentialSchema == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in other places, I think we should completely remove.
Fixes #493