Skip to content

Commit 108f699

Browse files
authored
Merge pull request #43 from contentstack/feat/DX-740-Taxonomy-Permissions
feat: add Taxonomy Permission in Role Model
2 parents 67ce75d + b4eb887 commit 108f699

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

.github/workflows/sca-scan.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ jobs:
66
security-sca:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@master
9+
- name: Checkout repository
10+
uses: actions/checkout@master
11+
- name: Run Dotnet Restore
12+
run: |
13+
dotnet restore
1014
- name: Run Snyk to check for vulnerabilities
1115
uses: snyk/actions/dotnet@master
1216
env:
1317
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
1418
with:
15-
args: --fail-on=all
19+
args: --file=Contentstack.Management.Core/obj/project.assets.json --fail-on=all

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ packages/
2424
*/mono**
2525
*/appSettings.json
2626
api_referece/*
27-
.sonarqube/
28-
CSManagementSDK.snk
27+
.sonarqube/

CSManagementSDK.snk

596 Bytes
Binary file not shown.

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)