Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerwowen committed Nov 14, 2024
1 parent 03990e2 commit 5110eba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void updateEnvStageOffDev_unsetsAllowPrivateBuild() throws Exception {
origBean.setStage_type(EnvType.DEV);
envBean.setStage_type(EnvType.STAGING);
Mockito.when(environDAO.getByStage(Mockito.anyString(), Mockito.anyString()))
.thenReturn(origBean);
.thenReturn(origBean);
SecurityContext mockSC = mock(SecurityContext.class);
Principal mockPrincipal = mock(Principal.class);
Mockito.when(mockSC.getUserPrincipal()).thenReturn(mockPrincipal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.pinterest.teletraan.universal.security.bean.AuthZResource;
import com.pinterest.teletraan.universal.security.bean.ScriptTokenPrincipal;
import com.pinterest.teletraan.universal.security.bean.ValueBasedRole;
import io.dropwizard.auth.AuthenticationException;
Expand Down Expand Up @@ -50,12 +51,14 @@ void setUp() throws Exception {
registry = new SimpleMeterRegistry();
Metrics.addRegistry(registry);

scriptTokenPrincipal =
new ScriptTokenPrincipal<ValueBasedRole>(
PRINCIPAL_NAME, new ValueBasedRole(1), new AuthZResource("rId", "rType"));

scriptTokenProvider = mock(ScriptTokenProvider.class);
scriptTokenPrincipal = mock(ScriptTokenPrincipal.class);
when(scriptTokenProvider.getPrincipal(anyString())).thenReturn(Optional.empty());
when(scriptTokenProvider.getPrincipal(CREDENTIALS))
.thenReturn(Optional.of(scriptTokenPrincipal));
when(scriptTokenPrincipal.getName()).thenReturn(PRINCIPAL_NAME);

sut = new ScriptTokenAuthenticator<>(scriptTokenProvider);
}
Expand Down

0 comments on commit 5110eba

Please sign in to comment.