Skip to content
This repository has been archived by the owner on Aug 25, 2019. It is now read-only.

Commit

Permalink
Fix format of restrictions (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmarkovski authored and tplooker committed Mar 30, 2019
1 parent 262aa2e commit bb802e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 58 deletions.
11 changes: 0 additions & 11 deletions src/AgentFramework.Core/AgentFramework.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\AgentFramework.Core.xml</DocumentationFile>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Models\Messaging\**" />
<EmbeddedResource Remove="Models\Messaging\**" />
<None Remove="Models\Messaging\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
Expand All @@ -29,10 +24,4 @@
<PackageReference Include="System.Reactive" Version="4.1.2" />
<PackageReference Include="System.Reactive.Linq" Version="4.1.2" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>
<ItemGroup>
<Folder Include="Messages\Common\" />
</ItemGroup>
</Project>
34 changes: 19 additions & 15 deletions src/AgentFramework.Core/Models/Proofs/ProofAttributeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@
namespace AgentFramework.Core.Models.Proofs
{
/// <summary>Attribute filter</summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum AttributeFilter
public class AttributeFilter
{
/// <summary>The schema identifier</summary>
[EnumMember(Value = "schema_id")]
SchemaId,
[JsonProperty("schema_id", NullValueHandling = NullValueHandling.Ignore)]
public string SchemaId { get; set; }

/// <summary>The schema issuer did</summary>
[EnumMember(Value = "schema_issuer_did")]
SchemaIssuerDid,
[JsonProperty("schema_issuer_did", NullValueHandling = NullValueHandling.Ignore)]
public string SchemaIssuerDid { get; set; }

/// <summary>The schema name</summary>
[EnumMember(Value = "schema_name")]
SchemaName,
[JsonProperty("schema_name", NullValueHandling = NullValueHandling.Ignore)]
public string SchemaName { get; set; }

/// <summary>The schema version</summary>
[EnumMember(Value = "schema_version")]
SchemaVersion,
[JsonProperty("schema_version", NullValueHandling = NullValueHandling.Ignore)]
public string SchemaVersion { get; set; }

/// <summary>The issuer did</summary>
[EnumMember(Value = "issuer_did")]
IssuerDid,
[JsonProperty("issuer_did", NullValueHandling = NullValueHandling.Ignore)]
public string IssuerDid { get; set; }

/// <summary>The credential definition identifier</summary>
[EnumMember(Value = "cred_def_id")]
CredentialDefinitionId
[JsonProperty("cred_def_id", NullValueHandling = NullValueHandling.Ignore)]
public string CredentialDefinitionId { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -57,7 +61,7 @@ public class ProofAttributeInfo
/// </summary>
/// <value>The restrictions.</value>
[JsonProperty("restrictions", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<AttributeFilter, string> Restrictions { get; set; }
public List<AttributeFilter> Restrictions { get; set; }

/// <summary>
/// Gets or sets the non revoked interval.
Expand Down
32 changes: 0 additions & 32 deletions test/AgentFramework.Core.Tests/ConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,6 @@ namespace AgentFramework.Core.Tests
{
public class ConverterTests
{
[Fact]
public void EnumAttributeSerializesToJson()
{
var attributeFilter = new Dictionary<AttributeFilter, string>
{
{AttributeFilter.CredentialDefinitionId, "123"}
};

var json = attributeFilter.ToJson();

var jobj = JObject.Parse(json);

Assert.True(jobj.ContainsKey("cred_def_id"));
Assert.Equal("123", jobj.GetValue("cred_def_id"));
}

[Fact]
public void EnumAttributeDeserializesFromJson()
{
var attributeFilter = new Dictionary<AttributeFilter, string>
{
{AttributeFilter.SchemaIssuerDid, "123"}
};

var json = attributeFilter.ToJson();

var dict = JsonConvert.DeserializeObject<Dictionary<AttributeFilter, string>>(json);

Assert.True(dict.ContainsKey(AttributeFilter.SchemaIssuerDid));
Assert.Equal("123", dict[AttributeFilter.SchemaIssuerDid]);
}

[Fact]
public void SerializeAgentMessageWithDecorators()
{
Expand Down

0 comments on commit bb802e1

Please sign in to comment.