Skip to content

Commit

Permalink
Correct role name for cac auth verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeNeilson committed Oct 22, 2024
1 parent 1ae9287 commit 70b79e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cwms-data-api/src/main/java/cwms/cda/ApiServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public class ApiServlet extends HttpServlet {

// based on https://bitbucket.hecdev.net/projects/CWMS/repos/cwms_aaa/browse/IntegrationTests/src/test/resources/sql/load_testusers.sql
public static final String CWMS_USERS_ROLE = "CWMS Users";
public static final String CAC_USER = "cac_user";
public static final String CAC_USER = "cac_auth";
/** Default OFFICE where needed. Based on context. e.g. /cwms-data -> HQ, /spk-data -> SPK */
public static final String OFFICE_ID = "office_id";
public static final String DATA_SOURCE = "data_source";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource;

import cwms.cda.ApiServlet;
import cwms.cda.api.DataApiTestIT;
import cwms.cda.api.LocationController;
import cwms.cda.data.dao.AuthDao;
Expand Down Expand Up @@ -304,7 +305,7 @@ public void test_api_key_cannot_create_new_key(String authType, TestAccounts.Key
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.statusCode(is(HttpCode.FORBIDDEN.getStatus()))
.body("message",is("Missing roles {Role{name='cac_user'}}"));
.body("message",is("Missing roles {Role{name='" + ApiServlet.CAC_USER + "'}}"));
}

// delete api keys
Expand Down
8 changes: 5 additions & 3 deletions cwms-data-api/src/test/java/fixtures/TestAccounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@

import java.util.Arrays;

import cwms.cda.ApiServlet;

public class TestAccounts {


public enum KeyUser {
NONE("none",null,null,null,null, null), // Used for annotations
GUEST("guest",null,null,null, null, null), // USED as marker label for tests
SPK_NORMAL("l2hectest","l2hectest","1234567890","l2userkey","ATotallyRandomStringL2hectest","SPK", "CWMS Users", "cac_user"),
SPK_NORMAL2("l2hectest_vt","l2hectestvt","2345678901","l2userkey2","DiffrntStringL2hectest_vt","SPK", "CWMS Users", "cac_user"),
SWT_NORMAL("m5hectest","swt99db","1234567890","testkey2","ATotallyRandomStringM5hectest","SWT", "CWMS Users", "cac_user"),
SPK_NORMAL("l2hectest","l2hectest","1234567890","l2userkey","ATotallyRandomStringL2hectest","SPK", "CWMS Users", ApiServlet.CAC_USER),
SPK_NORMAL2("l2hectest_vt","l2hectestvt","2345678901","l2userkey2","DiffrntStringL2hectest_vt","SPK", "CWMS Users", ApiServlet.CAC_USER),
SWT_NORMAL("m5hectest","swt99db","1234567890","testkey2","ATotallyRandomStringM5hectest","SWT", "CWMS Users", ApiServlet.CAC_USER),
SPK_NO_ROLES("user2","user2",null,"User2key","user2SEssion", "SPK");

private final String name; // username
Expand Down

0 comments on commit 70b79e8

Please sign in to comment.