DotValve implements IValve { @Override public void authenticate(String username, String password) throws ValveAuthException { this.CLIENT.getJWT(username, password, "n/a"); } DotValve(Map<String, String> config);  DotValve(DotClient client, DotDelegator delegator); @Override String getName(); @Override String getDescription(); @Override String getObjectSelectionCapability(String WMLtypeIn); @Override @Async("asyncCustomTaskExecutor") CompletableFuture<String> getObject(QueryContext qc); static boolean trajHasSearchQueryArgs( QueryContext qc ); @Override @Async("asyncCustomTaskExecutor") CompletableFuture<String> createObject(QueryContext qc); @Override @Async("asyncCustomTaskExecutor") CompletableFuture<Boolean> deleteObject(QueryContext qc); @Override @Async("asyncCustomTaskExecutor") CompletableFuture<Boolean> updateObject(QueryContext qc); @Override void authenticate(String username, String password); Map<String, AbstractWitsmlObject[]> getCap();  }
@Test public void shouldSucceedAuthenticate() throws Exception { when(this.mockClient.getJWT(eq("goodUsername"), eq("goodPassword"), anyString())) .thenReturn(JWT.decode( "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiR29vZCBUb2tlbiJ9.II4bNgtahHhV4jl7dgGn8CGjVxZWwBMZht-4LXeqB_Y" ) ); this.valve.authenticate("goodUsername", "goodPassword"); verify(this.mockClient).getJWT(eq("goodUsername"), eq("goodPassword"), anyString()); verifyNoMoreInteractions(this.mockClient); }
@Test(expected = ValveAuthException.class) public void shouldFailAuthenticate() throws ValveAuthException { when(this.mockClient.getJWT(eq("badUsername"), eq("badPassword"), eq("n/a"))) .thenThrow(new ValveAuthException("")); this.valve.authenticate("badUsername", "badPassword"); }