Skip to content

Commit

Permalink
Added test for the NobodyAuthenticatedException
Browse files Browse the repository at this point in the history
  • Loading branch information
johanna-skylight committed Oct 10, 2023
1 parent fe3e72e commit 148b74e
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package gov.cdc.usds.simplereport.service;

import static org.junit.jupiter.api.Assertions.assertThrows;

import gov.cdc.usds.simplereport.service.errors.NobodyAuthenticatedException;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;

public class LoggedInAuthorizationServiceTest extends BaseServiceTest<DiseaseService> {
@Autowired LoggedInAuthorizationService loggedInAuthorizationService;

@Test
void findAllOrganizationRoles_NobodyAuthenticatedException() {
SecurityContextHolder.getContext().setAuthentication(null);
assertThrows(
NobodyAuthenticatedException.class,
() -> loggedInAuthorizationService.findAllOrganizationRoles());
}
}

0 comments on commit 148b74e

Please sign in to comment.