def did(): return ( DID() .management_key("man-key1", 0) .did_key("did-key1", DIDKeyPurpose.AuthenticationKey, priority_requirement=2) .service("gmail-service", "email-service", "https://gmail.com", 2) )
def full_did(): return ( DID() .management_key("man-key1", 0) .management_key("man-key2", 1, KeyType.ECDSA) .management_key("man-key3", 1) .management_key("man-key4", 2, KeyType.RSA) .did_key("did-key1", DIDKeyPurpose.AuthenticationKey, priority_requirement=2) .did_key( "did-key2", [DIDKeyPurpose.AuthenticationKey, DIDKeyPurpose.PublicKey], priority_requirement=3, ) .did_key("did-key3", DIDKeyPurpose.PublicKey, priority_requirement=1) .service("gmail-service", "email-service", "https://gmail.com", 2) .service( "banking-credential-service", "credential-store-service", "https://credentials.com", 0, ) )
def test_deactivation_with_no_management_key(self): with pytest.raises(RuntimeError): DID().deactivate()
def did(): return DID()
def empty_did(): return DID()
def did(): return DID().management_key("man-key1", 0)
def create_new_did(): # New management key with default key type and controller management_key_1_alias = "my-first-management-key" management_key_1_priority = 0 # New management key with specified key type and controller management_key_2_alias = "my-second-management-key" management_key_2_priority = 2 management_key_2_type = KeyType.ECDSA management_key_2_controller = "{}:d3936b2f0bdd45fe71d7156e835434b7970afd78868076f56654d05f838b8005".format( DID_METHOD_NAME) # New public key with default key type and controller did_key_1_alias = "my-did-key-1" did_key_1_purpose = [DIDKeyPurpose.PublicKey] # New authentication key with specified key type did_key_2_alias = "my-did-key-2" did_key_2_purpose = [DIDKeyPurpose.AuthenticationKey] did_key_2_type = KeyType.RSA # New public and authentication key with specified key type, controller and priority requirement did_key_3_alias = "my-did-key-3" did_key_3_purpose = [ DIDKeyPurpose.PublicKey, DIDKeyPurpose.AuthenticationKey ] did_key_3_type = KeyType.EdDSA did_key_3_controller = "{}:d3936b2f0bdd45fe71d7156e835434b7970afd78868076f56654d05f838b8005".format( DID_METHOD_NAME) did_key_3_priority_requirement = 2 # New service service_alias = "my-photo-service" service_type = "PhotoStreamService" service_endpoint = "https://myphoto.com" service_priority_requirement = 1 service_custom_fields = { "description": "A photo stream service", "spamCost": { "amount": "0.50", "currency": "USD" }, } new_did = ( DID() # Can be mainnet/testnet or omitted entirely, in which case no network specifier will be added to the DID .testnet().management_key( management_key_1_alias, management_key_1_priority).management_key( management_key_2_alias, management_key_2_priority, management_key_2_type, management_key_2_controller, ).did_key(did_key_1_alias, did_key_1_purpose).did_key( did_key_2_alias, did_key_2_purpose, did_key_2_type).did_key( did_key_3_alias, did_key_3_purpose, did_key_3_type, did_key_3_controller, did_key_3_priority_requirement, ).service( service_alias, service_type, service_endpoint, service_priority_requirement, service_custom_fields, )) return new_did
def test_upgrade_with_no_management_key(self): with pytest.raises(RuntimeError): DID().method_spec_version_upgrade("1.0.0")