Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@
- Migrated `LocaleModel` and `BulkOperationModels` to use `System.Text.Json` attributes
- Added/updated unit and integration test coverage for Locale and Bulk Operations
- Upgraded target framework to .NET 10 and removed all build warnings
- **Note**:
- This is a beta release and APIs/modules may continue evolving during migration stabilization
- Release and Workflow setup within Bulk Operations module are currently commented out and will be uncommented once the Release and Workflow modules are migrated to System.Text.Json
- Remaining modules migrated and re-enabled — `AuditLog`, `Extension`, `Label`, `Role`, `Taxonomy`, `Term`, `Webhook`, `DeliveryToken`, `ManagementToken`, and `CustomExtension` fully re-enabled with STJ attributes; all corresponding `Stack.*()` accessor methods restored
- All `[JsonProperty]` replaced with `[JsonPropertyName]` across all model classes; `[JsonObject(ItemNullValueHandling)]` removed in favour of global `DefaultIgnoreCondition = WhenWritingNull`
- OAuth module enabled — `OAuthHandler`, `OAuthTokenService`, `OAuthAppAuthorizationService`, and `OAuthAppRevocationService` now active; auto token refresh wired into `InvokeAsync` pipeline via `EnsureOAuthTokenIsValidAsync`
- CustomWidgetModel scope serialization migrated from `JsonTextWriter` to `System.Text.Json.JsonSerializer.Serialize()`
- Asset extension upload tests — 3 previously skipped tests (`Test002_Should_Create_Dashboard`, `Test003_Should_Create_Custom_Widget`, `Test004_Should_Create_Custom_field`) now have real implementations
- Unit test coverage expanded — 991 → 1,242 passing tests; 24 previously excluded test files re-enabled covering AuditLog, Extension, Label, Role, Taxonomy, Term, Webhook, DeliveryToken, CustomExtension, and all infrastructure tests (HTTP pipeline, converters, runtime contexts, utilities)
- Integration test coverage expanded — 4 previously excluded integration test files re-enabled: ContentType Expanded (`Contentstack012b`), DeliveryToken (`Contentstack016`), Taxonomy (`Contentstack017`), Role (`Contentstack019`)

## [v0.10.0](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.9.0)
- Feat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,4 @@
<ProjectReference Include="..\Contentstack.Management.Core\contentstack.management.core.csproj" />
</ItemGroup>

<ItemGroup>
<!-- Exclude out-of-scope integration tests (still use Newtonsoft or depend on excluded SDK types) -->
<!-- Contentstack004_ReleaseTest.cs - RE-ENABLED for Release module STJ migration -->
<!-- Contentstack015_BulkOperationTest.cs - RE-ENABLED (Stack.Release() and Stack.Workflow() now active) -->
<!-- Contentstack020_WorkflowTest.cs - RE-ENABLED for Workflow module STJ migration -->
<Compile Remove="IntegrationTest\Contentstack012b_ContentTypeExpandedIntegrationTest.cs" />

</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net;
using System.Threading.Tasks;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Models.CustomExtension;
using Contentstack.Management.Core.Models.Fields;
using Contentstack.Management.Core.Tests.Helpers;
using Contentstack.Management.Core.Tests.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Threading.Tasks;
using System.Text;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Models.CustomExtension;
using Contentstack.Management.Core.Tests.Helpers;
using Contentstack.Management.Core.Tests.Model;
using Contentstack.Management.Core.Exceptions;
Expand Down Expand Up @@ -404,32 +405,92 @@ public async Task Test001_Should_Create_Asset()
}
}

// Tests 002-004 depend on Extension/CustomExtension SDK module (excluded from current scope)
[TestMethod]
[DoNotParallelize]
[Ignore("Requires Extension SDK module (Models/CustomExtension) which is out of current scope")]
public async Task Test002_Should_Create_Dashboard()
{
Assert.Inconclusive("Extension SDK module not available in current scope.");
await System.Threading.Tasks.Task.CompletedTask;
TestOutputLogger.LogContext("TestScenario", "CreateDashboardWidget");
var path = Path.Combine(System.Environment.CurrentDirectory, "../../../Mock/extension.html");
try
{
DashboardWidgetModel dashboard = new DashboardWidgetModel(
path, "text/html", "Integration Test Dashboard",
isEnable: true, defaultWidth: "half", tags: "dashboard,test");
ContentstackResponse response = await _stack.Extension().UploadAsync(dashboard);
TestOutputLogger.LogContext("StackAPIKey", _stack?.APIKey ?? "null");

if (response.IsSuccessStatusCode)
{
AssertLogger.IsNotNull(response.OpenJsonObjectResponse()["extension"], "CreateDashboard_ResponseContainsExtension");
}
else
{
AssertLogger.Fail("Dashboard Widget Creation Failed", response.OpenResponse());
}
}
catch (Exception e)
{
AssertLogger.Fail("Dashboard Widget Creation Failed", e.Message);
}
}

[TestMethod]
[DoNotParallelize]
[Ignore("Requires Extension SDK module (Models/CustomExtension) which is out of current scope")]
public async Task Test003_Should_Create_Custom_Widget()
{
Assert.Inconclusive("Extension SDK module not available in current scope.");
await System.Threading.Tasks.Task.CompletedTask;
TestOutputLogger.LogContext("TestScenario", "CreateCustomWidget");
var path = Path.Combine(System.Environment.CurrentDirectory, "../../../Mock/extension.html");
try
{
var scope = new ExtensionScope { ContentTypes = new List<string> { "$all" } };
CustomWidgetModel widget = new CustomWidgetModel(
path, "text/html", "Integration Test Widget",
tags: "widget,test", scope: scope);
ContentstackResponse response = await _stack.Extension().UploadAsync(widget);
TestOutputLogger.LogContext("StackAPIKey", _stack?.APIKey ?? "null");

if (response.IsSuccessStatusCode)
{
AssertLogger.IsNotNull(response.OpenJsonObjectResponse()["extension"], "CreateCustomWidget_ResponseContainsExtension");
}
else
{
AssertLogger.Fail("Custom Widget Creation Failed", response.OpenResponse());
}
}
catch (Exception e)
{
AssertLogger.Fail("Custom Widget Creation Failed", e.Message);
}
}

[TestMethod]
[DoNotParallelize]
[Ignore("Requires Extension SDK module (Models/CustomExtension) which is out of current scope")]
public async Task Test004_Should_Create_Custom_field()
{
Assert.Inconclusive("Extension SDK module not available in current scope.");
await System.Threading.Tasks.Task.CompletedTask;
TestOutputLogger.LogContext("TestScenario", "CreateCustomField");
var path = Path.Combine(System.Environment.CurrentDirectory, "../../../Mock/extension.html");
try
{
CustomFieldModel field = new CustomFieldModel(
path, "text/html", "Integration Test Field",
dataType: "text", isMultiple: false, tags: "field,test");
ContentstackResponse response = await _stack.Extension().UploadAsync(field);
TestOutputLogger.LogContext("StackAPIKey", _stack?.APIKey ?? "null");

if (response.IsSuccessStatusCode)
{
AssertLogger.IsNotNull(response.OpenJsonObjectResponse()["extension"], "CreateCustomField_ResponseContainsExtension");
}
else
{
AssertLogger.Fail("Custom Field Creation Failed", response.OpenResponse());
}
}
catch (Exception e)
{
AssertLogger.Fail("Custom Field Creation Failed", e.Message);
}
}

private string _testAssetUid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3665,7 +3665,7 @@ private async Task CreateTestRelease()
if (response.IsSuccessStatusCode && responseJson["release"] != null)
_testReleaseUid = responseJson["release"]["uid"].ToString();
}
catch (Exception e) { }
catch (Exception) { }
await Task.CompletedTask;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static bool RolesArrayContainsUid(JsonArray roles, string uid)
return false;
}

return roles.Any(r => r["uid"]?.ToString() == uid);
return roles.Any(r => r?["uid"]?.ToString() == uid);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,8 @@
</ItemGroup>

<ItemGroup>
<!-- Out-of-scope model tests (not in the 12-module migration) -->
<Compile Remove="Models\AuditLogTest.cs" />
<Compile Remove="Models\BaseModelTest.cs" />
<Compile Remove="Models\ExtensionTest.cs" />
<Compile Remove="Models\ExtensionModelTest.cs" />
<Compile Remove="Models\LabelTest.cs" />
<!-- PublishQueueTest.cs - RE-ENABLED for PublishQueue module STJ migration -->
<!-- PublishRuleTest.cs - RE-ENABLED for Workflow module STJ migration -->
<!-- ReleaseTest.cs - RE-ENABLED for Release module STJ migration -->
<!-- ReleaseItemTest.cs - RE-ENABLED for Release module STJ migration -->
<Compile Remove="Models\RoleTest.cs" />
<Compile Remove="Models\CustomExtensionTest.cs" />

<!-- OAuth tests (out of scope) -->
<!-- OAuth tests excluded: OAuth is a separate feature, not part of STJ migration -->
<Compile Remove="OAuth\**\*.cs" />

<!-- Infrastructure tests not yet migrated -->
<Compile Remove="Queryable\QueryTest.cs" />
<Compile Remove="Utils\TextNodeJsonConverterTest.cs" />
<Compile Remove="Utils\NodeJsonConverterTest.cs" />
<Compile Remove="Http\ContentstackHttpRequestTest.cs" />
<Compile Remove="Http\ContentstackHttpResponseTest.cs" />
<Compile Remove="Http\ContentstackErrorExceptionTest.cs" />
<Compile Remove="Utils\ContentstackUtilitiesTest.cs" />
<Compile Remove="Runtime\Pipeline\RetryHandler\RetryHandlerTest.cs" />
<Compile Remove="Runtime\Pipeline\ContentstackRuntimePipelineTest.cs" />
<Compile Remove="Runtime\Pipeline\RetryHandler\RetryHandlerIntegrationTest.cs" />
<Compile Remove="Runtime\Pipeline\HttpHandler\HttpHandlerTest.cs" />
<Compile Remove="Runtime\Pipeline\RetryHandler\DefaultRetryPolicyTest.cs" />
<Compile Remove="Runtime\Contexts\ContextTest.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void Should_Throw_Object_Disposed_Exception_On_Object_Dispose()
contentstackHttpResponse.Dispose();

Assert.ThrowsException<ObjectDisposedException>(() => contentstackHttpResponse.OpenResponse());
Assert.ThrowsException<ObjectDisposedException>(() => contentstackHttpResponse.OpenJObjectResponse());
Assert.ThrowsException<ObjectDisposedException>(() => contentstackHttpResponse.OpenJsonObjectResponse());
Assert.ThrowsException<ObjectDisposedException>(() => contentstackHttpResponse.OpenTResponse<StackModel>());

contentstackHttpResponse.Dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void Should_Fetch_AuditLog()
ContentstackResponse response = _stack.AuditLog(_fixture.Create<string>()).Fetch();

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -61,7 +61,7 @@ public async System.Threading.Tasks.Task Should_Fetch_AuditLog_Async()
ContentstackResponse response = await _stack.AuditLog(_fixture.Create<string>()).FetchAsync();

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -70,7 +70,7 @@ public void Should_Find_AuditLog()
ContentstackResponse response = _stack.AuditLog().FindAll();

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -79,7 +79,7 @@ public async System.Threading.Tasks.Task Should_Find_AuditLog_Async()
ContentstackResponse response = await _stack.AuditLog().FindAllAsync();

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

}
Expand Down
30 changes: 15 additions & 15 deletions Contentstack.Management.Core.Unit.Tests/Models/BaseModelTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using AutoFixture;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Unit.Tests.Mokes;
Expand Down Expand Up @@ -41,12 +41,12 @@ public void Initialize_ContentType()
BaseModel<ContentModelling> baseModel = new BaseModel<ContentModelling>(_stack, _fixture.Create<string>());

Assert.IsNull(baseModel.Uid);
Assert.ThrowsException<InvalidOperationException>(() => baseModel.Fetch());
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => baseModel.FetchAsync());
Assert.ThrowsException<InvalidOperationException>(() => baseModel.Update(new ContentModelling()));
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => baseModel.UpdateAsync(new ContentModelling()));
Assert.ThrowsException<InvalidOperationException>(() => baseModel.Delete());
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => baseModel.DeleteAsync());
Assert.ThrowsException<ArgumentException>(() => baseModel.Fetch());
Assert.ThrowsExceptionAsync<ArgumentException>(() => baseModel.FetchAsync());
Assert.ThrowsException<ArgumentException>(() => baseModel.Update(new ContentModelling()));
Assert.ThrowsExceptionAsync<ArgumentException>(() => baseModel.UpdateAsync(new ContentModelling()));
Assert.ThrowsException<ArgumentException>(() => baseModel.Delete());
Assert.ThrowsExceptionAsync<ArgumentException>(() => baseModel.DeleteAsync());

}
[TestMethod]
Expand All @@ -69,7 +69,7 @@ public void Should_Return_Mock_Response_On_Create()
ContentstackResponse response = baseModel.Create(new ContentModelling());

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -81,7 +81,7 @@ public async System.Threading.Tasks.Task Should_Return_Mock_Response_On_CreateAs
ContentstackResponse response = await baseModel.CreateAsync(new ContentModelling());

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -93,7 +93,7 @@ public void Should_Return_Mock_Response_On_Update()
ContentstackResponse response = baseModel.Update(new ContentModelling());

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -105,7 +105,7 @@ public async System.Threading.Tasks.Task Should_Return_Mock_Response_On_UpdateAs
ContentstackResponse response = await baseModel.UpdateAsync(new ContentModelling());

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -117,7 +117,7 @@ public void Should_Return_Mock_Response_On_Fetch()
ContentstackResponse response = baseModel.Fetch();

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -129,7 +129,7 @@ public async System.Threading.Tasks.Task Should_Return_Mock_Response_On_FetchAsy
ContentstackResponse response = await baseModel.FetchAsync();

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -141,7 +141,7 @@ public void Should_Return_Mock_Response_On_Delete()
ContentstackResponse response = baseModel.Delete();

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}

[TestMethod]
Expand All @@ -153,7 +153,7 @@ public async System.Threading.Tasks.Task Should_Return_Mock_Response_On_DeleteAs
ContentstackResponse response = await baseModel.DeleteAsync();

Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Contentstack.Management.Core.Models.CustomExtension;
using Contentstack.Management.Core.Models.Fields;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;

namespace Contentstack.Management.Core.Unit.Tests.Models
{
Expand Down
Loading
Loading