From 3942f0226e7961f6d3ee4f098c67c82d9bef340b Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Sat, 22 Apr 2023 10:40:26 -0400 Subject: [PATCH] compile fixes Signed-off-by: Andrew Azores --- .../web/http/api/v2/TargetsPostHandler.java | 39 ++++++++----------- .../http/api/v2/TargetsPostHandlerTest.java | 2 - 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/main/java/io/cryostat/net/web/http/api/v2/TargetsPostHandler.java b/src/main/java/io/cryostat/net/web/http/api/v2/TargetsPostHandler.java index 7fa05c850a..6b30268f54 100644 --- a/src/main/java/io/cryostat/net/web/http/api/v2/TargetsPostHandler.java +++ b/src/main/java/io/cryostat/net/web/http/api/v2/TargetsPostHandler.java @@ -180,28 +180,23 @@ public IntermediateResponse handle(RequestParameters params) throws ? Optional.empty() : Optional.of(new Credentials(username, password)); - if (credentials.isPresent()) { - if (storeCredentials) { - String matchExpression = - CredentialsManager.targetIdToMatchExpression(connectUrl); - int id = credentialsManager.addCredentials(matchExpression, credentials.get()); - notificationFactory - .createBuilder() - .metaCategory("CredentialsStored") - .metaType(HttpMimeType.JSON) - .message( - Map.of( - "id", - id, - "matchExpression", - matchExpression, - "numMatchingTargets", - 1)) - .build() - .send(); - } else { - credentialsManager.setSessionCredentials(uri.toString(), credentials.get()); - } + if (storeCredentials && credentials.isPresent()) { + String matchExpression = CredentialsManager.targetIdToMatchExpression(connectUrl); + int id = credentialsManager.addCredentials(matchExpression, credentials.get()); + notificationFactory + .createBuilder() + .metaCategory("CredentialsStored") + .metaType(HttpMimeType.JSON) + .message( + Map.of( + "id", + id, + "matchExpression", + matchExpression, + "numMatchingTargets", + 1)) + .build() + .send(); } String jvmId = jvmIdHelper.getJvmId(uri.toString(), false, credentials); diff --git a/src/test/java/io/cryostat/net/web/http/api/v2/TargetsPostHandlerTest.java b/src/test/java/io/cryostat/net/web/http/api/v2/TargetsPostHandlerTest.java index 7706aa3257..82351eff1f 100644 --- a/src/test/java/io/cryostat/net/web/http/api/v2/TargetsPostHandlerTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/v2/TargetsPostHandlerTest.java @@ -478,8 +478,6 @@ void testRequestWithDryRunQueryIncludingCredentials() throws Exception { IntermediateResponse response = handler.handle(params); MatcherAssert.assertThat(response.getStatusCode(), Matchers.equalTo(202)); - Mockito.verify(credentialsManager).setSessionCredentials(Mockito.any(), Mockito.any()); - ServiceRef respRef = response.getBody(); MatcherAssert.assertThat(respRef.getServiceUri(), Matchers.equalTo(new URI(connectUrl))); MatcherAssert.assertThat(respRef.getAlias(), Matchers.equalTo(Optional.of(alias)));