From 12969122f5b72fae1e573cf101614024ef797f7a Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 2 Dec 2024 06:37:21 -0800 Subject: [PATCH] chore: fixing userid format (#510) --- .../security/UserAuthenticationHelper.java | 2 +- .../UserAuthenticationHelperTest.java | 8 +++--- .../oracle/V003__oracle_test_data.sql | 27 +++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/security/UserAuthenticationHelper.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/security/UserAuthenticationHelper.java index 7952020c..b435e5f2 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/security/UserAuthenticationHelper.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/security/UserAuthenticationHelper.java @@ -67,7 +67,7 @@ public Optional getUserInfo() { // User id {IDIR@USERNAME} String cappedUsername = idpUsername.toUpperCase(); String cappedProvider = provider.toUpperCase(); - String userId = String.format("%s@%s", cappedProvider, cappedUsername); + String userId = String.format("%s\\%s", cappedProvider, cappedUsername); // Email will be empty, until next FAM release String email = jwtPrincipal.getClaimAsString("email"); diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/security/UserAuthenticationHelperTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/security/UserAuthenticationHelperTest.java index 97d8d54c..6bf13f87 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/security/UserAuthenticationHelperTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/security/UserAuthenticationHelperTest.java @@ -48,7 +48,7 @@ void getUserInfoIdirTest() { builder.claim("custom:idp_display_name", "from Baggings, Bilbo LWRS:EX"); builder.claim("custom:idp_username", "BAGGINGS"); builder.claim("custom:idp_name", "idir"); - builder.claim("cognito:username", "IDIR@BAGGINGS"); + builder.claim("cognito:username", "IDIR\\BAGGINGS"); builder.claim("client_roles", List.of("admin", "manager")); when(authentication.getPrincipal()).thenReturn(builder.build()); @@ -57,7 +57,7 @@ void getUserInfoIdirTest() { Assertions.assertTrue(userInfoOptional.isPresent()); UserInfo userInfo = userInfoOptional.get(); - Assertions.assertEquals("IDIR@BAGGINGS", userInfo.id()); + Assertions.assertEquals("IDIR\\BAGGINGS", userInfo.id()); Assertions.assertEquals("Bilbo", userInfo.firstName()); Assertions.assertEquals("Baggings", userInfo.lastName()); Assertions.assertEquals("bilbo.baggings@gov.bc.ca", userInfo.email()); @@ -85,7 +85,7 @@ void getUserInfoBusinessBceidTest() { builder.claim("custom:idp_display_name", "Lord Sauron of Mordor"); builder.claim("custom:idp_username", "MORDOR-BCEID"); builder.claim("custom:idp_name", "bceidbusiness"); - builder.claim("cognito:username", "BCEIDBUSINESS@MORDOR-BCEID"); + builder.claim("cognito:username", "BCEIDBUSINESS\\MORDOR-BCEID"); when(authentication.getPrincipal()).thenReturn(builder.build()); @@ -93,7 +93,7 @@ void getUserInfoBusinessBceidTest() { Assertions.assertTrue(userInfoOptional.isPresent()); UserInfo userInfo = userInfoOptional.get(); - Assertions.assertEquals("BCEIDBUSINESS@MORDOR-BCEID", userInfo.id()); + Assertions.assertEquals("BCEIDBUSINESS\\MORDOR-BCEID", userInfo.id()); Assertions.assertEquals("Lord", userInfo.firstName()); Assertions.assertEquals("Sauron of Mordor", userInfo.lastName()); Assertions.assertEquals("lord.sauron@mordor.middleearth", userInfo.email()); diff --git a/backend/src/test/resources/migration/oracle/V003__oracle_test_data.sql b/backend/src/test/resources/migration/oracle/V003__oracle_test_data.sql index 07c1b3df..2fd5e17a 100644 --- a/backend/src/test/resources/migration/oracle/V003__oracle_test_data.sql +++ b/backend/src/test/resources/migration/oracle/V003__oracle_test_data.sql @@ -134,26 +134,25 @@ INSERT INTO THE.STOCKING_EVENT_HISTORY REVISION_COUNT ) VALUES(111, 101, 101, 1, 'O', 'Results data conversion', 111, TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'Results data conversion', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1); - INSERT INTO THE.RESULTS_AUDIT_EVENT ( - RESULTS_AUDIT_EVENT_ID, - OPENING_ID, - STANDARDS_REGIME_ID, - SILVICULTURE_PROJECT_ID, - RESULTS_AUDIT_ACTION_CODE, - ACTION_DATE, - DESCRIPTION, - USER_ID, - EMAIL_SENT_IND, + RESULTS_AUDIT_EVENT_ID, + OPENING_ID, + STANDARDS_REGIME_ID, + SILVICULTURE_PROJECT_ID, + RESULTS_AUDIT_ACTION_CODE, + ACTION_DATE, + DESCRIPTION, + USER_ID, + EMAIL_SENT_IND, XML_SUBMISSION_ID, - OPENING_AMENDMENT_NUMBER, - ENTRY_USERID, + OPENING_AMENDMENT_NUMBER, + ENTRY_USERID, ENTRY_TIMESTAMP ) VALUES -(1, 101, NULL, NULL, 'SUB', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'Forest Cover 0000000', NULL, 'Y', 101, 101, 'TEST\OTTOMATED', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS')), -(2, 102, NULL, NULL, 'SUB', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'Forest Cover 0000000', NULL, 'Y', 102, 102, 'IDIR@TEST', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS')); +(1, 101, NULL, NULL, 'SUB', TIMESTAMP '2024-01-20 00:00:00.000000', 'Forest Cover 0000000', NULL, 'Y', 101, 101, 'TEST\OTTOMATED', TIMESTAMP '2024-01-20 00:00:00.000000'), +(2, 102, NULL, NULL, 'SUB', TIMESTAMP '2024-01-20 00:00:00.000000', 'Forest Cover 0000000', NULL, 'Y', 102, 102, 'IDIR\TEST', TIMESTAMP '2024-01-20 00:00:00.000000'); INSERT INTO THE.ACTIVITY_TREATMENT_UNIT (