From f71cffc9994b3f5fef8982caa7216f453702ee6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remi=20L=C3=B8voll?= Date: Fri, 26 Jan 2024 11:40:50 +0100 Subject: [PATCH 1/3] Fix apim deploy --- src/Altinn.Profile/Controllers/UsersController.cs | 4 ++-- .../IntegrationTests/UserProfileTests.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Altinn.Profile/Controllers/UsersController.cs b/src/Altinn.Profile/Controllers/UsersController.cs index b4b7478..e0958b7 100644 --- a/src/Altinn.Profile/Controllers/UsersController.cs +++ b/src/Altinn.Profile/Controllers/UsersController.cs @@ -58,11 +58,11 @@ public async Task> Get(int userID) /// /// The user uuid /// The information about a given user - [HttpGet("{userUuid:Guid}")] + [HttpGet("")] [Authorize(Policy = "PlatformAccess")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task> Get(Guid userUuid) + public async Task> Get([FromQuery] Guid userUuid) { UserProfile result = await _userProfilesWrapper.GetUserByUuid(userUuid); if (result == null) diff --git a/test/Altinn.Profile.Tests/IntegrationTests/UserProfileTests.cs b/test/Altinn.Profile.Tests/IntegrationTests/UserProfileTests.cs index 692fd23..143870c 100644 --- a/test/Altinn.Profile.Tests/IntegrationTests/UserProfileTests.cs +++ b/test/Altinn.Profile.Tests/IntegrationTests/UserProfileTests.cs @@ -161,7 +161,7 @@ public async Task GetUsersByUuid_SblBridgeFindsProfile_ResponseOk_ReturnsUserPro }); _webApplicationFactorySetup.SblBridgeHttpMessageHandler = messageHandler; - HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users/{userUuid}"); + HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users?userUuid={userUuid}"); httpRequestMessage.Headers.Add("PlatformAccessToken", PrincipalUtil.GetAccessToken("ttd", "unittest")); @@ -196,7 +196,7 @@ public async Task GetUsersByUuid_UserAuthenticatedMissingPlatformAccesToken_Retu const int userId = 20000009; Guid userUuid = new("cc86d2c7-1695-44b0-8e82-e633243fdf31"); - HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users/{userUuid}"); + HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users?userUuid={userUuid}"); HttpClient client = _webApplicationFactorySetup.GetTestServerClient(); @@ -223,7 +223,7 @@ public async Task GetUsersByUuid_SblBridgeReturnsNotFound_ResponseNotFound() }); _webApplicationFactorySetup.SblBridgeHttpMessageHandler = messageHandler; - HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users/{userUuid}"); + HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users?userUuid={userUuid}"); httpRequestMessage.Headers.Add("PlatformAccessToken", PrincipalUtil.GetAccessToken("ttd", "unittest")); @@ -246,7 +246,7 @@ public async Task GetUsersByUuid_MissingAuthentication_NotAuthorized() // Arrange Guid userUuid = new("cc86d2c7-1695-44b0-8e82-e633243fdf31"); - HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, $"/profile/api/v1/users/{userUuid}"); + HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, $"/profile/api/v1/users?userUuid={userUuid}"); httpRequestMessage.Headers.Add("PlatformAccessToken", PrincipalUtil.GetAccessToken("ttd", "unittest")); From 38b9ac0d631dc616d21f6d3ccdfd71a608ab1120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remi=20L=C3=B8voll?= Date: Fri, 26 Jan 2024 14:30:59 +0100 Subject: [PATCH 2/3] Changed to include uniqe value in path insted of adding Query parameters after review --- src/Altinn.Profile/Controllers/UsersController.cs | 4 ++-- .../IntegrationTests/UserProfileTests.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Altinn.Profile/Controllers/UsersController.cs b/src/Altinn.Profile/Controllers/UsersController.cs index e0958b7..386796b 100644 --- a/src/Altinn.Profile/Controllers/UsersController.cs +++ b/src/Altinn.Profile/Controllers/UsersController.cs @@ -58,11 +58,11 @@ public async Task> Get(int userID) /// /// The user uuid /// The information about a given user - [HttpGet("")] + [HttpGet("byuuid/{userUuid:Guid}")] [Authorize(Policy = "PlatformAccess")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task> Get([FromQuery] Guid userUuid) + public async Task> Get(Guid userUuid) { UserProfile result = await _userProfilesWrapper.GetUserByUuid(userUuid); if (result == null) diff --git a/test/Altinn.Profile.Tests/IntegrationTests/UserProfileTests.cs b/test/Altinn.Profile.Tests/IntegrationTests/UserProfileTests.cs index 143870c..1f0c946 100644 --- a/test/Altinn.Profile.Tests/IntegrationTests/UserProfileTests.cs +++ b/test/Altinn.Profile.Tests/IntegrationTests/UserProfileTests.cs @@ -161,7 +161,7 @@ public async Task GetUsersByUuid_SblBridgeFindsProfile_ResponseOk_ReturnsUserPro }); _webApplicationFactorySetup.SblBridgeHttpMessageHandler = messageHandler; - HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users?userUuid={userUuid}"); + HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users/byuuid/{userUuid}"); httpRequestMessage.Headers.Add("PlatformAccessToken", PrincipalUtil.GetAccessToken("ttd", "unittest")); @@ -196,7 +196,7 @@ public async Task GetUsersByUuid_UserAuthenticatedMissingPlatformAccesToken_Retu const int userId = 20000009; Guid userUuid = new("cc86d2c7-1695-44b0-8e82-e633243fdf31"); - HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users?userUuid={userUuid}"); + HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users/byuuid/{userUuid}"); HttpClient client = _webApplicationFactorySetup.GetTestServerClient(); @@ -223,7 +223,7 @@ public async Task GetUsersByUuid_SblBridgeReturnsNotFound_ResponseNotFound() }); _webApplicationFactorySetup.SblBridgeHttpMessageHandler = messageHandler; - HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users?userUuid={userUuid}"); + HttpRequestMessage httpRequestMessage = CreateGetRequest(userId, $"/profile/api/v1/users/byuuid/{userUuid}"); httpRequestMessage.Headers.Add("PlatformAccessToken", PrincipalUtil.GetAccessToken("ttd", "unittest")); @@ -246,7 +246,7 @@ public async Task GetUsersByUuid_MissingAuthentication_NotAuthorized() // Arrange Guid userUuid = new("cc86d2c7-1695-44b0-8e82-e633243fdf31"); - HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, $"/profile/api/v1/users?userUuid={userUuid}"); + HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, $"/profile/api/v1/users/byuuid/{userUuid}"); httpRequestMessage.Headers.Add("PlatformAccessToken", PrincipalUtil.GetAccessToken("ttd", "unittest")); From 6ccb53a10e8cf5005ead0dcfb0439157e780e724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remi=20L=C3=B8voll?= Date: Fri, 26 Jan 2024 14:51:16 +0100 Subject: [PATCH 3/3] Added specification to where the uuid should be fetched --- src/Altinn.Profile/Controllers/UsersController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Altinn.Profile/Controllers/UsersController.cs b/src/Altinn.Profile/Controllers/UsersController.cs index 386796b..41d13b3 100644 --- a/src/Altinn.Profile/Controllers/UsersController.cs +++ b/src/Altinn.Profile/Controllers/UsersController.cs @@ -62,7 +62,7 @@ public async Task> Get(int userID) [Authorize(Policy = "PlatformAccess")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task> Get(Guid userUuid) + public async Task> Get([FromRoute] Guid userUuid) { UserProfile result = await _userProfilesWrapper.GetUserByUuid(userUuid); if (result == null)