diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/20240919142711_2.3.0-alpha.1.Designer.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/20240919142711_2.3.0-alpha.1.Designer.cs
index b637e3812c..a50cb7cbcb 100644
--- a/src/portalbackend/PortalBackend.Migrations/Migrations/20240919142711_2.3.0-alpha.1.Designer.cs
+++ b/src/portalbackend/PortalBackend.Migrations/Migrations/20240919142711_2.3.0-alpha.1.Designer.cs
@@ -1,4 +1,4 @@
-/********************************************************************************
+/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -18,14 +18,11 @@
********************************************************************************/
//
-using System;
-using System.Text.Json;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities;
+using System.Text.Json;
#nullable disable
diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/20240919142711_2.3.0-alpha.1.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/20240919142711_2.3.0-alpha.1.cs
index 2ae95a49b3..37e9339a42 100644
--- a/src/portalbackend/PortalBackend.Migrations/Migrations/20240919142711_2.3.0-alpha.1.cs
+++ b/src/portalbackend/PortalBackend.Migrations/Migrations/20240919142711_2.3.0-alpha.1.cs
@@ -18,7 +18,6 @@
********************************************************************************/
using Microsoft.EntityFrameworkCore.Migrations;
-using System;
#nullable disable
diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs
index 08d70b8125..618e062cb6 100644
--- a/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs
+++ b/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs
@@ -1,4 +1,4 @@
-/********************************************************************************
+/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs
index 1aac18e2aa..2279da64dd 100644
--- a/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs
+++ b/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs
@@ -25,7 +25,6 @@
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Encryption;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
@@ -219,6 +218,11 @@ public async Task GetOwnCompanyServiceAccountDetailsAsync_WithValidInput_GetsAll
// Assert
result.Should().NotBeNull();
result.IamClientAuthMethod.Should().Be(IamClientAuthMethod.SECRET);
+ result.Secret.Should().Be("topsecret");
+ result.AuthenticationServiceUrl.Should().Be("https://auth.test/auth");
+ result.CompanyServiceAccountKindId.Should().Be(CompanyServiceAccountKindId.INTERNAL);
+ A.CallTo(() => _provisioningManager.GetIdOfCentralClientAsync(A._)).MustHaveHappenedOnceExactly();
+ A.CallTo(() => _provisioningManager.GetCentralClientAuthDataAsync(A._)).MustHaveHappenedOnceExactly();
}
[Fact]
@@ -235,58 +239,12 @@ public async Task GetOwnCompanyServiceAccountDetailsAsync_WithValidInputAndDimCo
result.Should().NotBeNull();
result.Secret.Should().Be("test");
result.IamClientAuthMethod.Should().Be(IamClientAuthMethod.SECRET);
+ result.AuthenticationServiceUrl.Should().Be("https://example.org/auth");
+ result.CompanyServiceAccountKindId.Should().Be(CompanyServiceAccountKindId.EXTERNAL);
A.CallTo(() => _provisioningManager.GetIdOfCentralClientAsync(A._)).MustNotHaveHappened();
A.CallTo(() => _provisioningManager.GetCentralClientAuthDataAsync(A._)).MustNotHaveHappened();
}
- [Fact]
- public async Task GetOwnCompanyServiceAccountDetailsAsync_WithValidUserTypeInternal_AuthenticationUrl()
- {
- // Arrange
- SetupGetOwnComapnyServiceAccountInternalType();
- var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement);
-
- // Act
- var result = await sut.GetOwnCompanyServiceAccountDetailsAsync(ValidServiceAccountId);
-
- // Assert
- result.Should().NotBeNull();
- result.CompanyServiceAccountKindId.Should().Be(CompanyServiceAccountKindId.INTERNAL);
- result.AuthenticationServiceUrl.Should().Be("https://auth.test/auth");
- }
-
- [Fact]
- public async Task GetOwnCompanyServiceAccountDetailsAsync_WithValidUserTypeExternal_AuthenticationUrl()
- {
- // Arrange
- SetupGetOwnComapnyServiceAccountExternalType();
- var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement);
-
- // Act
- var result = await sut.GetOwnCompanyServiceAccountDetailsAsync(ValidServiceAccountId);
-
- // Assert
- result.Should().NotBeNull();
- result.CompanyServiceAccountKindId.Should().Be(CompanyServiceAccountKindId.EXTERNAL);
- result.AuthenticationServiceUrl.Should().Be("https://test.org/auth");
- }
-
- [Fact]
- public async Task GetOwnCompanyServiceAccountDetailsAsync_WithInValidUserTypeInternal_AuthenticationUrl()
- {
- // Arrange
- SetupGetOwnCompanyServiceAccountDetails();
- var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement);
-
- // Act
- var result = await sut.GetOwnCompanyServiceAccountDetailsAsync(ValidServiceAccountId);
-
- // Assert
- result.Should().NotBeNull();
- result.CompanyServiceAccountKindId.Should().NotBe(CompanyServiceAccountKindId.INTERNAL);
- result.AuthenticationServiceUrl.Should().NotBe("https://auth.test/auth");
- }
-
[Fact]
public async Task GetOwnCompanyServiceAccountDetailsAsync_WithInvalidCompany_NotFoundException()
{
@@ -839,16 +797,23 @@ private void SetupUpdateOwnCompanyServiceAccountDetails()
private void SetupGetOwnCompanyServiceAccount()
{
+ var data = _fixture.Build()
+ .With(x => x.Status, UserStatusId.ACTIVE)
+ .With(x => x.DimServiceAccountData, default(DimServiceAccountData?))
+ .With(x => x.CompanyServiceAccountKindId, CompanyServiceAccountKindId.INTERNAL)
+ .Create();
+
var cryptoHelper = _options.Value.EncryptionConfigs.GetCryptoHelper(_options.Value.EncryptionConfigIndex);
var (secret, initializationVector) = cryptoHelper.Encrypt("test");
var dimServiceAccountData = new DimServiceAccountData("https://example.org/auth", secret, initializationVector, _options.Value.EncryptionConfigIndex);
var dataWithDim = _fixture.Build()
.With(x => x.DimServiceAccountData, dimServiceAccountData)
+ .With(x => x.CompanyServiceAccountKindId, CompanyServiceAccountKindId.EXTERNAL)
.Create();
A.CallTo(() => _serviceAccountRepository.GetOwnCompanyServiceAccountDetailedDataUntrackedAsync(ValidServiceAccountId, ValidCompanyId))
- .Returns(dataWithDim);
+ .Returns(data);
A.CallTo(() => _serviceAccountRepository.GetOwnCompanyServiceAccountDetailedDataUntrackedAsync(ValidServiceAccountWithDimDataId, ValidCompanyId))
.Returns(dataWithDim);
A.CallTo(() => _serviceAccountRepository.GetOwnCompanyServiceAccountDetailedDataUntrackedAsync(
@@ -858,35 +823,6 @@ private void SetupGetOwnCompanyServiceAccount()
.Returns(null);
}
- private void SetupGetOwnComapnyServiceAccountInternalType()
- {
- var data = _fixture.Build()
- .With(x => x.Status, UserStatusId.ACTIVE)
- .With(x => x.CompanyServiceAccountKindId, CompanyServiceAccountKindId.INTERNAL)
- .With(x => x.DimServiceAccountData, default(DimServiceAccountData?))
- .Create();
-
- A.CallTo(() => _serviceAccountRepository.GetOwnCompanyServiceAccountDetailedDataUntrackedAsync(ValidServiceAccountId, ValidCompanyId))
- .Returns(data);
- }
-
- private void SetupGetOwnComapnyServiceAccountExternalType()
- {
- var cryptoHelper = _options.Value.EncryptionConfigs.GetCryptoHelper(_options.Value.EncryptionConfigIndex);
- var (secret, initializationVector) = cryptoHelper.Encrypt("test");
-
- var dimServiceAccountData = new DimServiceAccountData("https://test.org/auth", secret, initializationVector, _options.Value.EncryptionConfigIndex);
-
- var externalData = _fixture.Build()
- .With(x => x.Status, UserStatusId.ACTIVE)
- .With(x => x.CompanyServiceAccountKindId, CompanyServiceAccountKindId.EXTERNAL)
- .With(x => x.DimServiceAccountData, dimServiceAccountData)
- .Create();
-
- A.CallTo(() => _serviceAccountRepository.GetOwnCompanyServiceAccountDetailedDataUntrackedAsync(ValidServiceAccountId, ValidCompanyId))
- .Returns(externalData);
- }
-
private void SetupDeleteOwnCompanyServiceAccount(Connector? connector = null, Identity? identity = null, Guid? processId = null)
{
var serviceAccount = new CompanyServiceAccount(Guid.NewGuid(), Guid.NewGuid(), "test-sa", "test", CompanyServiceAccountTypeId.OWN, CompanyServiceAccountKindId.INTERNAL);