-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Matthew.Spence-VE-3338-Issuer-Setup-v0.7' into 'main'
VE 3338: Add issuerSetup v0.7 to sdk Closes VE-3338 See merge request evernym/verity/verity-sdk!97
- Loading branch information
Showing
17 changed files
with
984 additions
and
17 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
sdk/dotnet-sdk/src/VeritySDK.Test/Protocols/IssuerSetup/IssuerSetupTest_0_6.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Json; | ||
using VeritySDK.Protocols.IssuerSetup; | ||
using VeritySDK.Utils; | ||
|
||
namespace VeritySDK.Test | ||
{ | ||
[TestClass] | ||
public class IssuerSetupTest_0_6 : TestBase | ||
{ | ||
|
||
[TestMethod] | ||
public void testGetMessageType() | ||
{ | ||
string msgName = "msg name"; | ||
|
||
IssuerSetupV0_6 t = IssuerSetup.v0_6(); | ||
|
||
string expectedType = Util.getMessageType( | ||
Util.EVERNYM_MSG_QUALIFIER, | ||
t.family(), | ||
t.version(), | ||
msgName); | ||
|
||
Assert.AreEqual(expectedType, t.messageType(msgName)); | ||
} | ||
|
||
[TestMethod] | ||
public void testGetThreadId() | ||
{ | ||
IssuerSetupV0_6 testProtocol = IssuerSetup.v0_6(); | ||
Assert.IsNotNull(testProtocol.getThreadId()); | ||
} | ||
|
||
[TestMethod] | ||
public void testCreateMessages() | ||
{ | ||
Context context = TestHelpers.getContext(); | ||
IssuerSetupV0_6 p = IssuerSetup.v0_6(); | ||
JsonObject msg = p.createMsg(context); | ||
Assert.AreEqual( | ||
Util.EVERNYM_MSG_QUALIFIER + "/issuer-setup/0.6/create", | ||
msg.getAsString("@type") | ||
); | ||
Assert.IsNotNull(msg.getAsString("@id")); | ||
} | ||
|
||
[TestMethod] | ||
public void testCreate() | ||
{ | ||
withContext(context => | ||
{ | ||
IssuerSetupV0_6 testProtocol = IssuerSetup.v0_6(); | ||
byte[] message = testProtocol.createMsgPacked(context); | ||
JsonObject unpackedMessage = TestHelpers.unpackForwardMessage(context, message); | ||
Assert.AreEqual( | ||
Util.EVERNYM_MSG_QUALIFIER + "/issuer-setup/0.6/create", | ||
unpackedMessage.getAsString("@type")); | ||
}); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
191 changes: 191 additions & 0 deletions
191
sdk/dotnet-sdk/src/VeritySDK/Protocols/IssuerSetup/v0_7/IssuerSetupV0_7.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
using System.Json; | ||
using VeritySDK.Protocols; | ||
using VeritySDK.Utils; | ||
|
||
namespace VeritySDK.Protocols.IssuerSetup | ||
{ | ||
/// <summary> | ||
/// A class for controlling a 0.7 IssuerSetup protocol. | ||
/// </summary> | ||
public class IssuerSetupV0_7 : AbstractProtocol | ||
{ | ||
#region Protocol identificator | ||
|
||
/// <summary> | ||
/// The qualifier for the message family. Uses Evernym's qualifier. | ||
/// </summary> | ||
public override string qualifier() { return Util.EVERNYM_MSG_QUALIFIER; } | ||
|
||
/// <summary> | ||
/// The name for the message family. | ||
/// </summary> | ||
public override string family() { return "issuer-setup"; } | ||
|
||
/// <summary> | ||
/// The version for the message family. | ||
/// </summary> | ||
public override string version() { return "0.7"; } | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
public IssuerSetupV0_7() { } | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
public IssuerSetupV0_7(string threadId) : base(threadId) { } | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Name for 'create' control message | ||
/// </summary> | ||
public string CREATE = "create"; | ||
|
||
/// <summary> | ||
/// Name for 'current-public-identifier' control message | ||
/// </summary> | ||
public string CURRENT_PUBLIC_IDENTIFIER = "current-public-identifier"; | ||
|
||
/// <summary> | ||
/// Directs verity-application to start and create an issuer identity and set it up | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
/// <param name="ledgerPrefix">a string indicating the location that the issuer identifier should be published to. Verity can publish to the following locations, indicated by the values in quotes: | ||
/// [Sovrin Builder Net: "did:indy:sovrin:builder", | ||
/// Sovrin Staging Net: "did:indy:sovrin:staging", | ||
/// Sovrin Main Net: "did:indy:sovrin"] | ||
/// The locations which are available to your Verity tenant will be configured based on your customer agreement.</param> | ||
public void create(Context context, string ledgerPrefix) | ||
{ | ||
send(context, createMsg(context, ledgerPrefix)); | ||
} | ||
|
||
/// <summary> | ||
/// Directs verity-application to start and create an issuer identity and set it up | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
/// <param name="ledgerPrefix">a string indicating the location that the issuer identifier should be published to. Verity can publish to the following locations, indicated by the values in quotes: | ||
/// [Sovrin Builder Net: "did:indy:sovrin:builder", | ||
/// Sovrin Staging Net: "did:indy:sovrin:staging", | ||
/// Sovrin Main Net: "did:indy:sovrin"] | ||
/// The locations which are available to your Verity tenant will be configured based on your customer agreement.</param> | ||
/// <param name="endorser">Optional: the desired endorser did. If left empty then Verity will attempt to use it's own endorser, otherwise it will return a transaction for manual endorsement</param> | ||
public void create(Context context, string ledgerPrefix, string endorser) | ||
{ | ||
send(context, createMsg(context, ledgerPrefix, endorser)); | ||
} | ||
|
||
/// <summary> | ||
/// Creates the control message without packaging and sending it. | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
/// <param name="ledgerPrefix">a string indicating the location that the issuer identifier should be published to. Verity can publish to the following locations, indicated by the values in quotes: | ||
/// [Sovrin Builder Net: "did:indy:sovrin:builder", | ||
/// Sovrin Staging Net: "did:indy:sovrin:staging", | ||
/// Sovrin Main Net: "did:indy:sovrin"] | ||
/// The locations which are available to your Verity tenant will be configured based on your customer agreement.</param> | ||
/// <returns>the constructed message (JSON object)</returns> | ||
public JsonObject createMsg(Context context, string ledgerPrefix) | ||
{ | ||
JsonObject message = new JsonObject(); | ||
message.Add("@type", messageType(CREATE)); | ||
message.Add("@id", getNewId()); | ||
message.Add("ledgerPrefix", ledgerPrefix); | ||
addThread(message); | ||
return message; | ||
} | ||
|
||
/// <summary> | ||
/// Creates the control message without packaging and sending it. | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
/// <param name="ledgerPrefix">a string indicating the location that the issuer identifier should be published to. Verity can publish to the following locations, indicated by the values in quotes: | ||
/// [Sovrin Builder Net: "did:indy:sovrin:builder", | ||
/// Sovrin Staging Net: "did:indy:sovrin:staging", | ||
/// Sovrin Main Net: "did:indy:sovrin"] | ||
/// The locations which are available to your Verity tenant will be configured based on your customer agreement.</param> | ||
/// <param name="endorser">Optional: the desired endorser did. If left empty then Verity will attempt to use it's own endorser, otherwise it will return a transaction for manual endorsement</param> | ||
/// <returns>the constructed message (JSON object)</returns> | ||
public JsonObject createMsg(Context context, string ledgerPrefix, string endorser) | ||
{ | ||
JsonObject message = new JsonObject(); | ||
message.Add("@type", messageType(CREATE)); | ||
message.Add("@id", getNewId()); | ||
message.Add("endorser", endorser); | ||
message.Add("ledgerPrefix", ledgerPrefix); | ||
addThread(message); | ||
return message; | ||
} | ||
|
||
/// <summary> | ||
/// Creates and packages message without sending it. | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
/// <param name="ledgerPrefix">a string indicating the location that the issuer identifier should be published to. Verity can publish to the following locations, indicated by the values in quotes: | ||
/// [Sovrin Builder Net: "did:indy:sovrin:builder", | ||
/// Sovrin Staging Net: "did:indy:sovrin:staging", | ||
/// Sovrin Main Net: "did:indy:sovrin"] | ||
/// The locations which are available to your Verity tenant will be configured based on your customer agreement.</param> | ||
/// <returns>the byte array ready for transport</returns> | ||
public byte[] createMsgPacked(Context context, string ledgerPrefix) | ||
{ | ||
return packMsg(context, createMsg(context, ledgerPrefix)); | ||
} | ||
|
||
/// <summary> | ||
/// Creates and packages message without sending it. | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
/// <param name="ledgerPrefix">a string indicating the location that the issuer identifier should be published to. Verity can publish to the following locations, indicated by the values in quotes: | ||
/// [Sovrin Builder Net: "did:indy:sovrin:builder", | ||
/// Sovrin Staging Net: "did:indy:sovrin:staging", | ||
/// Sovrin Main Net: "did:indy:sovrin"] | ||
/// The locations which are available to your Verity tenant will be configured based on your customer agreement.</param> | ||
/// <param name="endorser">Optional: the desired endorser did. If left empty then Verity will attempt to use it's own endorser, otherwise it will return a transaction for manual endorsement</param> | ||
/// <returns>the byte array ready for transport</returns> | ||
public byte[] createMsgPacked(Context context, string ledgerPrefix, string endorser) | ||
{ | ||
return packMsg(context, createMsg(context, ledgerPrefix, endorser)); | ||
} | ||
|
||
/// <summary> | ||
/// Asks the verity-application for the current issuer identity that is setup. | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
public void currentPublicIdentifier(Context context) | ||
{ | ||
send(context, currentPublicIdentifierMsg(context)); | ||
} | ||
|
||
/// <summary> | ||
/// Creates the control message without packaging and sending it. | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
/// <returns>the constructed message (JSON object)</returns> | ||
public JsonObject currentPublicIdentifierMsg(Context context) | ||
{ | ||
JsonObject message = new JsonObject(); | ||
message.Add("@type", messageType(CURRENT_PUBLIC_IDENTIFIER)); | ||
message.Add("@id", getNewId()); | ||
addThread(message); | ||
return message; | ||
} | ||
|
||
/// <summary> | ||
/// Creates and packages message without sending it. | ||
/// </summary> | ||
/// <param name="context">an instance of the Context object initialized to a verity-application agent</param> | ||
/// <returns>the byte array ready for transport</returns> | ||
public byte[] currentPublicIdentifierMsgPacked(Context context) | ||
{ | ||
return packMsg(context, currentPublicIdentifierMsg(context)); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.