From 90cf31e3058663dbef61da9535b5a3a2a9a75aa9 Mon Sep 17 00:00:00 2001 From: weskubo-cgi Date: Tue, 15 Feb 2022 13:26:19 -0800 Subject: [PATCH] Updated unit tests. --- .../hnweb/security/SecurityPropertiesTest.java | 2 +- .../gov/hlth/hnweb/security/SecurityUtilTest.java | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/security/SecurityPropertiesTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/security/SecurityPropertiesTest.java index 290621da..a73f1c6d 100644 --- a/backend/src/test/java/ca/bc/gov/hlth/hnweb/security/SecurityPropertiesTest.java +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/security/SecurityPropertiesTest.java @@ -18,7 +18,7 @@ public class SecurityPropertiesTest { @Test public void testGetProperties_success() { Map> rolePermissions = securityProperties.getRolePermissions(); - assertEquals(3, rolePermissions.size()); + assertEquals(4, rolePermissions.size()); List e45Permissions = rolePermissions.get("E45"); assertEquals(1, e45Permissions.size()); diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/security/SecurityUtilTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/security/SecurityUtilTest.java index c0a597ba..9ff59319 100644 --- a/backend/src/test/java/ca/bc/gov/hlth/hnweb/security/SecurityUtilTest.java +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/security/SecurityUtilTest.java @@ -30,8 +30,19 @@ public void testLoadPermissions_E45() { } @Test - public void testLoadPermissions_Eligibility() { - Jwt jwt = createToken("Eligibility"); + public void testLoadPermissions_ELIGIBILITY() { + Jwt jwt = createToken("ELIGIBILITY"); + + List permissions = SecurityUtil.loadPermissions(jwt, securityProperties.getRolePermissions()); + assertEquals(3, permissions.size()); + assertEquals("E45", permissions.get(0)); + assertEquals("R15", permissions.get(1)); + assertEquals("R41", permissions.get(2)); + } + + @Test + public void testLoadPermissions_TRAININGHEALTHAUTH() { + Jwt jwt = createToken("TRAININGHEALTHAUTH"); List permissions = SecurityUtil.loadPermissions(jwt, securityProperties.getRolePermissions()); assertEquals(3, permissions.size());