diff --git a/.github/workflows/check-branch.yml b/.github/workflows/check-branch.yml index 0690dbc..00a6a8a 100644 --- a/.github/workflows/check-branch.yml +++ b/.github/workflows/check-branch.yml @@ -8,13 +8,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Comment PR - if: github.base_ref == 'main' && github.head_ref != 'next' + if: github.base_ref == 'main' && github.head_ref != 'staging' uses: thollander/actions-comment-pull-request@v2 with: message: | We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch. - name: Check branch - if: github.base_ref == 'main' && github.head_ref != 'next' + if: github.base_ref == 'main' && github.head_ref != 'staging' run: | echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch." exit 1 diff --git a/Contentstack.Management.ASPNETCore/LICENSE.txt b/Contentstack.Management.ASPNETCore/LICENSE.txt index 3333caa..501f936 100644 --- a/Contentstack.Management.ASPNETCore/LICENSE.txt +++ b/Contentstack.Management.ASPNETCore/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright © 2012-2024 Contentstack. All Rights Reserved +Copyright © 2012-2025 Contentstack. All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Contentstack.Management.ASPNETCore/contentstack.management.aspnetcore.csproj b/Contentstack.Management.ASPNETCore/contentstack.management.aspnetcore.csproj index 49a3a1f..5458abb 100644 --- a/Contentstack.Management.ASPNETCore/contentstack.management.aspnetcore.csproj +++ b/Contentstack.Management.ASPNETCore/contentstack.management.aspnetcore.csproj @@ -5,7 +5,7 @@ contentstack.management.aspnetcore $(Version) Contentstack - Copyright © 2012-2024 Contentstack. All Rights Reserved + Copyright © 2012-2025 Contentstack. All Rights Reserved Contentstack https://github.com/contentstack/contentstack-management-dotnet Initial Release @@ -15,7 +15,7 @@ .NET SDK for the Contentstack Content Management API. LICENSE.txt v$(Version) - 0.1.3 + $(Version) Contentstack.Management.ASPNETCore @@ -28,7 +28,7 @@ - + diff --git a/Contentstack.Management.Core.Unit.Tests/Models/DeliveryTokenTest.cs b/Contentstack.Management.Core.Unit.Tests/Models/DeliveryTokenTest.cs new file mode 100644 index 0000000..40dd87c --- /dev/null +++ b/Contentstack.Management.Core.Unit.Tests/Models/DeliveryTokenTest.cs @@ -0,0 +1,133 @@ +using System; +using System.Threading.Tasks; +using AutoFixture; +using Contentstack.Management.Core.Models; +using Contentstack.Management.Core.Models.Token; +using Contentstack.Management.Core.Queryable; +using Contentstack.Management.Core.Unit.Tests.Mokes; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Contentstack.Management.Core.Unit.Tests.Models +{ + [TestClass] + public class DeliveryTokenTest + { + private Stack _stack; + private readonly IFixture _fixture = new Fixture(); + private ContentstackResponse _contentstackResponse; + + [TestInitialize] + public void initialize() + { + var client = new ContentstackClient(); + _contentstackResponse = MockResponse.CreateContentstackResponse("MockResponse.txt"); + client.ContentstackPipeline.ReplaceHandler(new MockHttpHandler(_contentstackResponse)); + client.contentstackOptions.Authtoken = _fixture.Create(); + _stack = new Stack(client, _fixture.Create()); + } + + [TestMethod] + public void Initialize_DeliveryToken() + { + DeliveryToken token = new DeliveryToken(_stack); + Assert.IsNull(token.Uid); + Assert.AreEqual("stacks/delivery_tokens", token.resourcePath); + Assert.ThrowsException(() => token.Fetch()); + Assert.ThrowsExceptionAsync(() => token.FetchAsync()); + Assert.ThrowsException(() => token.Update(_fixture.Create())); + Assert.ThrowsExceptionAsync(() => token.UpdateAsync(_fixture.Create())); + Assert.ThrowsException(() => token.Delete()); + Assert.ThrowsExceptionAsync(() => token.DeleteAsync()); + Assert.AreEqual(token.Query().GetType(), typeof(Query)); + } + + [TestMethod] + public void Initialize_DeliveryToken_With_Uid() + { + string uid = _fixture.Create(); + DeliveryToken token = new DeliveryToken(_stack, uid); + Assert.AreEqual(uid, token.Uid); + Assert.AreEqual($"stacks/delivery_tokens/{uid}", token.resourcePath); + } + + [TestMethod] + public void Should_Create_DeliveryToken() + { + ContentstackResponse response = _stack.DeliveryToken().Create(_fixture.Create()); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public async Task Should_Create_DeliveryToken_Async() + { + ContentstackResponse response = await _stack.DeliveryToken().CreateAsync(_fixture.Create()); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public void Should_Query_DeliveryToken() + { + ContentstackResponse response = _stack.DeliveryToken().Query().Find(); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public async Task Should_Query_DeliveryToken_Async() + { + ContentstackResponse response = await _stack.DeliveryToken().Query().FindAsync(); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public void Should_Fetch_DeliveryToken() + { + ContentstackResponse response = _stack.DeliveryToken(_fixture.Create()).Fetch(); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public async Task Should_Fetch_DeliveryToken_Async() + { + ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create()).FetchAsync(); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public void Should_Update_DeliveryToken() + { + ContentstackResponse response = _stack.DeliveryToken(_fixture.Create()).Update(_fixture.Create()); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public async Task Should_Update_DeliveryToken_Async() + { + ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create()).UpdateAsync(_fixture.Create()); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public void Should_Delete_DeliveryToken() + { + ContentstackResponse response = _stack.DeliveryToken(_fixture.Create()).Delete(); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + + [TestMethod] + public async Task Should_Delete_DeliveryToken_Async() + { + ContentstackResponse response = await _stack.DeliveryToken(_fixture.Create()).DeleteAsync(); + Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse()); + Assert.AreEqual(_contentstackResponse.OpenJObjectResponse().ToString(), response.OpenJObjectResponse().ToString()); + } + } +} diff --git a/Contentstack.Management.Core/LICENSE.txt b/Contentstack.Management.Core/LICENSE.txt index 3333caa..501f936 100644 --- a/Contentstack.Management.Core/LICENSE.txt +++ b/Contentstack.Management.Core/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright © 2012-2024 Contentstack. All Rights Reserved +Copyright © 2012-2025 Contentstack. All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Contentstack.Management.Core/Models/Token/DeliveryToken.cs b/Contentstack.Management.Core/Models/Token/DeliveryToken.cs index 27f71e4..75396ac 100644 --- a/Contentstack.Management.Core/Models/Token/DeliveryToken.cs +++ b/Contentstack.Management.Core/Models/Token/DeliveryToken.cs @@ -1,5 +1,7 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Contentstack.Management.Core.Queryable; +using Newtonsoft.Json.Linq; namespace Contentstack.Management.Core.Models.Token { @@ -8,7 +10,7 @@ public class DeliveryToken : BaseModel internal DeliveryToken(Stack stack, string uid = null) : base(stack, "token", uid) { - resourcePath = uid == null ? "/delivery_tokens" : $"/delivery_tokens/{uid}"; + resourcePath = uid == null ? "stacks/delivery_tokens" : $"stacks/delivery_tokens/{uid}"; } /// diff --git a/Contentstack.Management.Core/contentstack.management.core.csproj b/Contentstack.Management.Core/contentstack.management.core.csproj index 94b1097..828e971 100644 --- a/Contentstack.Management.Core/contentstack.management.core.csproj +++ b/Contentstack.Management.Core/contentstack.management.core.csproj @@ -4,7 +4,7 @@ netstandard2.0;net471;net472; Contentstack Management Contentstack - Copyright © 2012-2024 Contentstack. All Rights Reserved + Copyright © 2012-2025 Contentstack. All Rights Reserved .NET SDK for the Contentstack Content Management API. Contentstack contentstack.management.csharp diff --git a/Scripts/run-test-case.sh b/Scripts/run-test-case.sh index 871d404..7550df9 100644 --- a/Scripts/run-test-case.sh +++ b/Scripts/run-test-case.sh @@ -4,7 +4,7 @@ # Contentstack # # Created by Uttam Ukkoji on 12/04/21. -# Copyright © 2024 Contentstack. All rights reserved. +# Copyright © 2025 Contentstack. All rights reserved. echo "Removing files" diff --git a/Scripts/run-unit-test-case.sh b/Scripts/run-unit-test-case.sh index d1f34fd..ff14bdc 100644 --- a/Scripts/run-unit-test-case.sh +++ b/Scripts/run-unit-test-case.sh @@ -4,7 +4,7 @@ # Contentstack # # Created by Uttam Ukkoji on 30/03/2023. -# Copyright © 2024 Contentstack. All rights reserved. +# Copyright © 2025 Contentstack. All rights reserved. echo "Removing files" rm -rf "./Contentstack.Management.Core.Unit.Tests/TestResults"