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

initial version of create-schema rpc #49

Merged
merged 1 commit into from
Feb 12, 2022
Merged

Conversation

arnabghose997
Copy link
Contributor

Tests for create-schema RPC

Valid create-schema command

hid-noded tx ssi create-schema  '{"type":"https://w3c-ccg.github.io/vc-json-schemas/schema/1.0/schema.json","modelVersion":"v1.0","id":"did:hs:abcdefghi;id=17de181feb67447da4e78259d92d0240;version=1.0","name":"HS credential template","author":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51","authored":"Tue Apr 06 2021 00:09:56 GMT+0530 (India Standard Time)","schema":{"schema":"https://json-schema.org/draft-07/schema#","description":"test","type":"object","properties":"{myString:{type:string},myNumner:{type:number},myBool:{type:boolean}}","required":["myString","myNumner","myBool"],"additionalProperties":false}}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Valid create-did command

hid-noded tx ssi create-did '{
"context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/v1",
"https://schema.org"
],
"type": "https://schema.org/Person",
"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51",
"name": "Vishwas",
"publicKey": [
{
"context": "https://w3id.org/security/v2",
"id": "did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf",
"type": "Ed25519VerificationKey2020",
"publicKeyBase58": "zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
}
],
"authentication": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"assertionMethod": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"keyAgreement": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"capabilityInvocation": [
"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf"
],
"created": "2021-04-06T14:13:14.018Z",
"updated": "2021-04-06T14:13:14.018Z"
}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Scenario 1: Creating the Schema when the DID doesn't exists in the chain

Running the valid create-schema CLI command gives the following error output:

raw_log: 'failed to execute message; message index: 0: The DID did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51
  is not available: not found'

Scenario 2: Trying to creating the schema again, even though that same Schema is already registered.

The output:

raw_log: 'failed to execute message; message index: 0: Schema ID:  did:hs:abcdefghi;id=17de181feb67447da4e78259d92d0240;version=1.0:
  Schema already exists'

Scenario 3: Invalid Version Format in Schema ID

CLI for invalid version number in Schema ID

hid-noded tx ssi create-schema  '{"type":"https://w3c-ccg.github.io/vc-json-schemas/schema/1.0/schema.json","modelVersion":"v1.0","id":"did:hs:abcdefghi;id=17de181feb67447da4e78259d92d0240;version=updated","name":"HS credential template","author":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51","authored":"Tue Apr 06 2021 00:09:56 GMT+0530 (India Standard Time)","schema":{"schema":"https://json-schema.org/draft-07/schema#","description":"test","type":"object","properties":"{myString:{type:string},myNumner:{type:number},myBool:{type:boolean}}","required":["myString","myNumner","myBool"],"additionalProperties":false}}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: input version Id -> `updated`,
  is an invalid format: Invalid schema Id'

Scenario 4: Invalid Schema Prefix in Schema ID

CLI:

hid-noded tx ssi create-schema  '{"type":"https://w3c-ccg.github.io/vc-json-schemas/schema/1.0/schema.json","modelVersion":"v1.0","id":"did:something:abcdefghi;id=17de181feb67447da4e78259d92d0240;version=1.0","name":"HS credential template","author":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51","authored":"Tue Apr 06 2021 00:09:56 GMT+0530 (India Standard Time)","schema":{"schema":"https://json-schema.org/draft-07/schema#","description":"test","type":"object","properties":"{myString:{type:string},myNumner:{type:number},myBool:{type:boolean}}","required":["myString","myNumner","myBool"],"additionalProperties":false}}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: Expected did:hs as prefix in
  schema ID, The Schema ID is did:something:abcdefghi;id=17de181feb67447da4e78259d92d0240;version=1.0:
  Invalid schema Id'

Scenario 5: Invalid Schema ID components count when separated by ; (Count != 3)

hid-noded tx ssi create-schema  '{"type":"https://w3c-ccg.github.io/vc-json-schemas/schema/1.0/schema.json","modelVersion":"v1.0","id":"did:hs:abcdefghi;id=17de181feb67447da4e78259d92d0240","name":"HS credential template","author":"did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51","authored":"Tue Apr 06 2021 00:09:56 GMT+0530 (India Standard Time)","schema":{"schema":"https://json-schema.org/draft-07/schema#","description":"test","type":"object","properties":"{myString:{type:string},myNumner:{type:number},myBool:{type:boolean}}","required":["myString","myNumner","myBool"],"additionalProperties":false}}' did:hs:0f49341a-20ef-43d1-bc93-de30993e6c51#zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf --ver-key oVtY1xceDZQjkfwlbCEC2vgeADcxpgd27vtYasBhcM/JLR6PnPoD9jvjSJrMsMJwS7faPy5OlFCdj/kgLVZMEg== --from alice --chain-id hidnode

Result:

raw_log: 'failed to execute message; message index: 0: Expected 3 components in schema
  ID after being seperated by `;`, got 2 components. The Schema ID is `did:hs:abcdefghi;id=17de181feb67447da4e78259d92d0240`
  : Invalid schema Id'

@arnabghose997 arnabghose997 merged commit 95dde6a into main Feb 12, 2022
@arnabghose997 arnabghose997 self-assigned this Feb 13, 2022
@arnabghose997 arnabghose997 deleted the create-schema-module-ssi branch February 21, 2022 04:41
This was linked to issues Mar 22, 2022
@Vishwas1 Vishwas1 added the ssi label Mar 24, 2022
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.

Implement Query Schema Implement Create Schema RPC on node
2 participants