Skip to content

Commit

Permalink
Upgrade to BugFix version 3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
juileetikekar committed Oct 28, 2024
1 parent 2890023 commit 1897991
Show file tree
Hide file tree
Showing 3 changed files with 456 additions and 570 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

namespace AasxServerBlazorTests.Controllers;

using System.Reflection.Emit;
using System.Security.Claims;
using System.Security.Principal;
using System.Xml.Linq;
using AasCore.Aas3_0;
using AasxServer;
using AasxServerStandardBib.Interfaces;
Expand Down Expand Up @@ -282,9 +284,10 @@ public void GetAllSubmodelElements_WithValidRequest_ReturnsPagedResult(string su

_authorizationServiceMock.Setup(x => x.AuthorizeAsync(It.IsAny<ClaimsPrincipal>(), It.IsAny<ISubmodel>(), "SecurityPolicy"))
.Returns(Task.FromResult(AuthorizationResult.Success()));

var levelString = nameof(level);
var extentString = nameof(extent);
// Act
var result = _controller.GetAllSubmodelElements(submodelIdentifier, limit, cursor, level, extent, diff);
var result = _controller.GetAllSubmodelElements(submodelIdentifier, limit, cursor, levelString, extentString, diff);

// Assert
result.Should().BeOfType<ObjectResult>();
Expand All @@ -303,8 +306,11 @@ public void GetAllSubmodelElements_WhenDecodingReturnedNull_ThrowsNotAllowedExce

_decoderServiceMock.Setup(x => x.Decode("submodelIdentifier", submodelIdentifier)).Returns((string)null);

var levelString = nameof(LevelEnum.Deep);
var extentString = nameof(ExtentEnum.WithoutBlobValue);

// Act
Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, LevelEnum.Deep, ExtentEnum.WithoutBlobValue, null);
Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, levelString, extentString, null);

// Assert
action.Should().ThrowExactly<AasSecurity.Exceptions.NotAllowed>().WithMessage($"Decoding {submodelIdentifier} returned null");
Expand All @@ -325,8 +331,11 @@ public void GetAllSubmodelElements_WhenAuthorizationFails_ThrowsNotAllowedExcept

Program.noSecurity = false;

var levelString = nameof(LevelEnum.Core);
var extentString = nameof(ExtentEnum.WithBlobValue);

// Act
Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, LevelEnum.Core, ExtentEnum.WithBlobValue, null);
Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, levelString, extentString, null);

// Assert
action.Should().ThrowExactly<AasSecurity.Exceptions.NotAllowed>();
Expand All @@ -352,8 +361,12 @@ public void GetAllSubmodelElements_WithValidRequestAndDiffParameter_FiltersSubmo

//_paginationServiceMock.Setup(x => x.GetPaginatedList(It.IsAny<List<ISubmodelElement>>(), It.IsAny<PaginationParameters>()))
// .Returns((List<ISubmodelElement> elements, PaginationParameters parameters) => new List<ISubmodelElement>(elements));

var levelString = nameof(LevelEnum.Deep);
var extentString = nameof(ExtentEnum.WithoutBlobValue);

// Act
Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, LevelEnum.Deep, ExtentEnum.WithBlobValue, diffParameterValue);
Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, levelString, extentString, diffParameterValue);

// Assert
action.Should().NotThrow(); // Ensure no exception is thrown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Constructor_ShouldThrowArgumentNullException_WhenSubmodelServiceIsNu
public void GenerateSerializationByIds_ShouldReturnEmptyEnvironment_WhenNoIdsProvided()
{
// Arrange
_mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny<List<SpecificAssetId>?>(), It.IsAny<string?>())).Returns([]);
_mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny<List<ISpecificAssetId>?>(), It.IsAny<string?>())).Returns([]);
_mockSubmodelService.Setup(x => x.GetAllSubmodels()).Returns([]);

// Act
Expand All @@ -79,7 +79,7 @@ public void GenerateSerializationByIds_ShouldFetchAASs_WhenAasIdsProvided()
var mockAas = new Mock<IAssetAdministrationShell>();
mockAas.SetupGet(x => x.Id).Returns(aasId);

_mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny<List<SpecificAssetId>?>(), It.IsAny<string?>())).Returns([mockAas.Object]);
_mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny<List<ISpecificAssetId>?>(), It.IsAny<string?>())).Returns([mockAas.Object]);
_mockSubmodelService.Setup(x => x.GetAllSubmodels()).Returns([]);

// Act
Expand All @@ -98,7 +98,7 @@ public void GenerateSerializationByIds_ShouldFetchSubmodels_WhenSubmodelIdsProvi
var mockSubmodel = new Mock<ISubmodel>();
mockSubmodel.SetupGet(x => x.Id).Returns(submodelId);

_mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny<List<SpecificAssetId>?>(), It.IsAny<string?>())).Returns([]);
_mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny<List<ISpecificAssetId>?>(), It.IsAny<string?>())).Returns([]);
_mockSubmodelService.Setup(x => x.GetAllSubmodels()).Returns([mockSubmodel.Object]);

// Act
Expand All @@ -122,7 +122,7 @@ public void GenerateSerializationByIds_ShouldFetchAASsAndSubmodels_WhenBothIdsPr
var mockSubmodel = new Mock<ISubmodel>();
mockSubmodel.SetupGet(x => x.Id).Returns(submodelId);

_mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny<List<SpecificAssetId>?>(), It.IsAny<string?>())).Returns([mockAas.Object]);
_mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny<List<ISpecificAssetId>?>(), It.IsAny<string?>())).Returns([mockAas.Object]);
_mockSubmodelService.Setup(x => x.GetAllSubmodels()).Returns([mockSubmodel.Object]);

// Act
Expand Down
Loading

0 comments on commit 1897991

Please sign in to comment.