This is an automated email from the ASF dual-hosted git repository.
wuzhiguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new b01a819b09 AMBARI-25459: Ambari doesn't show versions page after
invalid repo was added (#3525)
b01a819b09 is described below
commit b01a819b09585f20b73855f1c31e27e59f1692d2
Author: Yu Hou <[email protected]>
AuthorDate: Thu Nov 17 17:15:15 2022 +0800
AMBARI-25459: Ambari doesn't show versions page after invalid repo was
added (#3525)
---
.../main/java/org/apache/ambari/server/utils/URLCredentialsHider.java | 4 ++--
.../java/org/apache/ambari/server/utils/URLCredentialsHiderTest.java | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/utils/URLCredentialsHider.java
b/ambari-server/src/main/java/org/apache/ambari/server/utils/URLCredentialsHider.java
index bb3a79a7b1..52d612b277 100644
---
a/ambari-server/src/main/java/org/apache/ambari/server/utils/URLCredentialsHider.java
+++
b/ambari-server/src/main/java/org/apache/ambari/server/utils/URLCredentialsHider.java
@@ -45,9 +45,9 @@ public class URLCredentialsHider {
String userInfo = url.getUserInfo();
if (StringUtils.isNotEmpty(userInfo)) {
if (userInfo.contains(":")) {
- return urlString.replaceFirst(userInfo, HIDDEN_CREDENTIALS);
+ return StringUtils.replaceOnce(urlString, userInfo,
HIDDEN_CREDENTIALS);
} else {
- return urlString.replaceFirst(userInfo, HIDDEN_USER);
+ return StringUtils.replaceOnce(urlString, userInfo, HIDDEN_USER);
}
}
return urlString;
diff --git
a/ambari-server/src/test/java/org/apache/ambari/server/utils/URLCredentialsHiderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/utils/URLCredentialsHiderTest.java
index 241a437f7c..772950a046 100644
---
a/ambari-server/src/test/java/org/apache/ambari/server/utils/URLCredentialsHiderTest.java
+++
b/ambari-server/src/test/java/org/apache/ambari/server/utils/URLCredentialsHiderTest.java
@@ -37,5 +37,9 @@ public class URLCredentialsHiderTest {
String invalidURL = "htt://user01:pass@host:8443/api/v1";
Assert.assertEquals(URLCredentialsHider.INVALID_URL,
URLCredentialsHider.hideCredentials(invalidURL));
+
+ String testURL3 = "http://***:***@host:8443/api/v1";
+ Assert.assertEquals(String.format("http://%s@host:8443/api/v1",
URLCredentialsHider.HIDDEN_CREDENTIALS),
+ URLCredentialsHider.hideCredentials(testURL3));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]