Skip to content

Commit 0c3cc4d

Browse files
Merge pull request #110 from contentstack/staging
Staging
2 parents dfad702 + e6a58d3 commit 0c3cc4d

File tree

16 files changed

+1164
-457
lines changed

16 files changed

+1164
-457
lines changed

.github/workflows/secrets-scan.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Secrets Scan
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
jobs:
6+
security-secrets:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
fetch-depth: '2'
12+
ref: '${{ github.event.pull_request.head.ref }}'
13+
- run: |
14+
git reset --soft HEAD~1
15+
- name: Install Talisman
16+
run: |
17+
# Download Talisman
18+
wget https://github.com/thoughtworks/talisman/releases/download/v1.37.0/talisman_linux_amd64 -O talisman
19+
20+
# Checksum verification
21+
checksum=$(sha256sum ./talisman | awk '{print $1}')
22+
if [ "$checksum" != "8e0ae8bb7b160bf10c4fa1448beb04a32a35e63505b3dddff74a092bccaaa7e4" ]; then exit 1; fi
23+
24+
# Make it executable
25+
chmod +x talisman
26+
- name: Run talisman
27+
run: |
28+
# Run Talisman with the pre-commit hook
29+
./talisman --githook pre-commit

.talismanrc

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
fileignoreconfig:
2+
- filename: .github/workflows/secrets-scan.yml
3+
ignore_detectors:
4+
- filecontent
25
- filename: Contentstack.Core/Internals/HttpRequestHandler.cs
36
checksum: 93c1659f3bc7527956f0fd12db46441297fac3a4366d273bcbb3425d2351300e
47
- filename: Contentstack.Core/Models/Entry.cs
5-
checksum: 79320b005882981fd7c79fe73832f28284db686927942e46b422ac9e88405023
8+
checksum: a6226f755dde69be62c21737ca75569ba6ea7cb4b7a125dc460c047dbe741b9e
69
- filename: Contentstack.Core/ContentstackClient.cs
7-
checksum: 1cb7c9bd62881ae71406449c948b1e85aa865d0c7191013f77f9b9a60df700d9
10+
checksum: 761a5d65bfa12d16641aa66e5431b2eb52b0909eff904dca5c2f607ee439cba0
811
- filename: Contentstack.Core/Models/AssetLibrary.cs
9-
checksum: 023aed649cf09228d753a4dec2b3a9f126aad474f538ca0e21d03ee07e9f6129
12+
checksum: 92ff3feaf730b57c50bb8429f08dd4cddedb42cd89f2507e9746f8237b65fb11
1013
- filename: Contentstack.Core/Models/Asset.cs
11-
checksum: 98b819cb9b1e6a9a9e5394ac23c07bc642a41c0c7512d169afc63afe3baa6fb3
14+
checksum: d192718723e6cb2aa8f08f873d3a7ea7268c89cc15da3bdeea4c16fd304c410e
1215
- filename: Contentstack.Core/Models/Query.cs
13-
checksum: eaf047e4ff77d92b5114f190e17fcc1e605bf8536e0406418d7ac1d0357d5110
16+
checksum: fb9b5e4014f937d66b9028b35ea53d750e4d2659daaa48a2941c02f37429725f
1417
- filename: Contentstack.Core/Models/Taxonomy.cs
15-
checksum: db8bcefdc7aafde4286e7fb6d67348bec49f1ac27b54d84fddca8124135bd779
18+
checksum: 751a725d94eff7d845bb22a5ce80a5529bb62971373de39288149fff3d024930
1619
- filename: .github/workflows/nuget-publish.yml
17-
checksum: 53ba4ce874c4d2362ad00deb23f5a6ec219318860352f997b945e9161a580651
20+
checksum: 53ba4ce874c4d2362ad00deb23f5a6ec219318860352f997b945e9161a580651
21+
- filename: Contentstack.Core/Models/ContentType.cs
22+
checksum: 53e3b8330183445d100b32c545073f281b869ee238514c7ab8c9a4500a140166
23+
- filename: Contentstack.Core.Tests/ContentTypeTest.cs
24+
checksum: a2549638af21492d5a299dce35a2994ec4721b211af6956b955602d7065c47dc
25+
- filename: Contentstack.Core/Models/GlobalFieldQuery.cs
26+
checksum: 16fb3c5fb4de2b686f338b0666c7c86c3d37f2a276f85698a59a1ac1a02d359d
27+
- filename: Contentstack.Core/Models/GlobalField.cs
28+
checksum: 49cc6ec8b55408a3e71ba19551dbe01709ec70bc673fae21c280a1f74968e395

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Version: 2.22.0
2+
#### Date: March-03-2025
3+
4+
##### Feat:
5+
- Added Support for Global Fields
6+
17
### Version: 2.21.0
28
#### Date: March-03-2025
39

Contentstack.Core.Tests/ContentTypeTest.cs

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Contentstack.Core.Models;
44
using System.Threading.Tasks;
55
using System.Collections.Generic;
6+
using Newtonsoft.Json.Linq;
67

78
namespace Contentstack.Core.Tests
89
{
@@ -79,5 +80,130 @@ public async Task GetContentTypesIncludeGlobalFields()
7980

8081
}
8182
}
83+
84+
[Fact]
85+
public async Task FetchGlobalFieldSchema()
86+
{
87+
string globalFieldUid = "global_field_uid";
88+
GlobalField globalField = client.GlobalField(globalFieldUid);
89+
90+
var result = await globalField.Fetch();
91+
Assert.NotNull(result);
92+
Assert.True(result.HasValues, "GlobalField.Fetch() did not return expected schema.");
93+
}
94+
95+
[Fact]
96+
public async Task FetchGlobalFieldSchema_InvalidUid_ThrowsOrReturnsNull()
97+
{
98+
string invalidUid = "invalid_uid";
99+
GlobalField globalField = client.GlobalField(invalidUid);
100+
await Assert.ThrowsAnyAsync<Exception>(async () => await globalField.Fetch());
101+
}
102+
103+
[Fact]
104+
public async Task FetchGlobalFieldSchema_WithParameters_ReturnsSchema()
105+
{
106+
string globalFieldUid = "global_field_uid";
107+
GlobalField globalField = client.GlobalField(globalFieldUid);
108+
var param = new Dictionary<string, object> { { "include_global_field_schema", true } };
109+
var result = await globalField.Fetch(param);
110+
Assert.NotNull(result);
111+
Assert.True(result.HasValues, "GlobalField.Fetch() with params did not return expected schema.");
112+
}
113+
114+
[Fact]
115+
public void SetAndRemoveHeader_WorksCorrectly()
116+
{
117+
string globalFieldUid = "global_field_uid";
118+
GlobalField globalField = client.GlobalField(globalFieldUid);
119+
globalField.SetHeader("custom_key", "custom_value");
120+
globalField.RemoveHeader("custom_key");
121+
Assert.True(true);
122+
}
123+
124+
[Fact]
125+
public async Task FetchGlobalFieldSchema_WithCustomHeader()
126+
{
127+
string globalFieldUid = "global_field_uid";
128+
GlobalField globalField = client.GlobalField(globalFieldUid);
129+
globalField.SetHeader("custom_key", "custom_value");
130+
var result = await globalField.Fetch();
131+
Assert.NotNull(result);
132+
}
133+
134+
[Fact]
135+
public async Task FetchGlobalFieldSchema_NullParameters_Succeeds()
136+
{
137+
string globalFieldUid = "global_field_uid";
138+
GlobalField globalField = client.GlobalField(globalFieldUid);
139+
var result = await globalField.Fetch(null);
140+
Assert.NotNull(result);
141+
}
142+
143+
[Fact]
144+
public void GlobalField_EmptyUid_Throws()
145+
{
146+
Assert.Throws<ArgumentNullException>(() => {
147+
GlobalField globalField = client.GlobalField("");
148+
});
149+
}
150+
151+
[Fact]
152+
public async Task GlobalFieldQuery_Find_ReturnsArray()
153+
{
154+
var query = client.GlobalFieldQuery();
155+
var result = await query.Find();
156+
157+
Assert.NotNull(result);
158+
}
159+
160+
[Fact]
161+
public async Task GlobalFieldQuery_Find_WithParameters_ReturnsArray()
162+
{
163+
var query = client.GlobalFieldQuery();
164+
var param = new Dictionary<string, object> { { "include_global_field_schema", true } };
165+
var result = await query.Find(param);
166+
Assert.NotNull(result);
167+
}
168+
169+
[Fact]
170+
public async Task GlobalFieldQuery_Find_WithSkipAndLimit_ReturnsArray()
171+
{
172+
var query = client.GlobalFieldQuery();
173+
var param = new Dictionary<string, object> { { "skip", 1 }, { "limit", 2 } };
174+
var result = await query.Find(param);
175+
Assert.Empty(result["global_fields"]);
176+
}
177+
178+
[Fact]
179+
public void GlobalFieldQuery_IncludeBranch_SetsQueryParam()
180+
{
181+
var query = client.GlobalFieldQuery();
182+
var result = query.IncludeBranch();
183+
Assert.NotNull(result);
184+
Assert.Equal(query, result);
185+
}
186+
187+
[Fact]
188+
public void GlobalFieldQuery_IncludeGlobalFieldSchema_SetsQueryParam()
189+
{
190+
var query = client.GlobalFieldQuery();
191+
var result = query.IncludeGlobalFieldSchema();
192+
Assert.NotNull(result);
193+
}
194+
195+
[Fact]
196+
public async Task GlobalFieldQuery_Find_InvalidParams_ThrowsOrReturnsEmpty()
197+
{
198+
var query = client.GlobalFieldQuery();
199+
var invalidParams = new Dictionary<string, object> { { "invalid_param", true } };
200+
201+
var result = await query.Find(invalidParams);
202+
203+
Assert.NotNull(result);
204+
Assert.IsType<JObject>(result);
205+
var globalFields = result["global_fields"] as JArray;
206+
Assert.NotNull(globalFields);
207+
}
82208
}
83209
}

0 commit comments

Comments
 (0)