Skip to content

Commit 48b2b6e

Browse files
committed
feat: add Taxonomy Permission in Role Model
1 parent 67ce75d commit 48b2b6e

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

Contentstack.Management.Core.Unit.Tests/Models/RoleTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,23 @@ public async System.Threading.Tasks.Task Should_Delete_Role_Async()
142142
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
143143
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
144144
}
145+
146+
[TestMethod]
147+
public void Should_Create_Role_With_Taxonomy_Permissions()
148+
{
149+
ContentstackResponse response = _stack.Role().Create(_fixture.Create<RoleModel>());
150+
151+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
152+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
153+
}
154+
155+
[TestMethod]
156+
public void Should_Update_Role_With_Taxonomy_Permissions()
157+
{
158+
ContentstackResponse response = _stack.Role(_fixture.Create<string>()).Update(_fixture.Create<RoleModel>());
159+
160+
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
161+
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
162+
}
145163
}
146164
}

Contentstack.Management.Core/Models/RoleModel.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ContentTypeRules: Rule
3636
public List<string> ContentTypes { get; set; }
3737
}
3838

39-
public class BrancheRules : Rule
39+
public class BranchRules : Rule
4040
{
4141
[JsonProperty(propertyName: "module")]
4242
public string Module { get; } = "branch";
@@ -80,4 +80,28 @@ public class EnvironmentRules : Rule
8080
[JsonProperty(propertyName: "environments")]
8181
public List<string> Environments { get; set; }
8282
}
83+
84+
public class TaxonomyContentType
85+
{
86+
[JsonProperty(propertyName: "uid")]
87+
public string Uid { get; set; }
88+
89+
[JsonProperty(propertyName: "acl")]
90+
public Dictionary<string, object> ACL { get; }
91+
}
92+
93+
public class TaxonomyRules : Rule
94+
{
95+
[JsonProperty(propertyName: "module")]
96+
public string Module { get; } = "taxonomy";
97+
98+
[JsonProperty(propertyName: "taxonomies")]
99+
public List<string> Taxonomies { get; set; }
100+
101+
[JsonProperty(propertyName: "terms")]
102+
public List<string> Terms { get; set; }
103+
104+
[JsonProperty(propertyName: "content_types")]
105+
public List<TaxonomyContentType> ContentTypes { get; set; }
106+
}
83107
}

0 commit comments

Comments
 (0)