[ 
https://issues.apache.org/jira/browse/KNOX-2747?focusedWorklogId=775251&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-775251
 ]

ASF GitHub Bot logged work on KNOX-2747:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/May/22 21:45
            Start Date: 26/May/22 21:45
    Worklog Time Spent: 10m 
      Work Description: zeroflag commented on code in PR #581:
URL: https://github.com/apache/knox/pull/581#discussion_r883106816


##########
gateway-server/src/test/java/org/apache/knox/gateway/services/security/impl/RemoteAliasServiceTestProvider.java:
##########
@@ -88,7 +88,8 @@ public void removeAliasesForCluster(String clusterName, 
Set<String> aliases) thr
 
     @Override
     public char[] getPasswordFromAliasForCluster(String clusterName, String 
alias) {
-      return aliases.getOrDefault(clusterName, new 
HashMap<>()).get(alias).toCharArray();
+      String value = aliases.getOrDefault(clusterName, new 
HashMap<>()).get(alias);
+      return value == null ? null : value.toCharArray();

Review Comment:
   It is because of the new test (this is also test code). We simulate that 
there is no password yet and check if the password was generated.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 775251)
    Time Spent: 0.5h  (was: 20m)

> RemoteAliasService generates password without checking if it already exists
> ---------------------------------------------------------------------------
>
>                 Key: KNOX-2747
>                 URL: https://issues.apache.org/jira/browse/KNOX-2747
>             Project: Apache Knox
>          Issue Type: Bug
>            Reporter: Attila Magyar
>            Assignee: Attila Magyar
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> RemoteAliasService:
> {code}
>     /* Generate a new password  */
>     if (generate) {
>       generateAliasForCluster(clusterName, alias);
>     }
> {code}
> DefaultAliasService checks first
> {code}
>       credential = keystoreService.getCredentialForCluster(clusterName, 
> alias);
>       if (credential == null && generate) {
>         generateAliasForCluster(clusterName, alias);
>         credential = keystoreService.getCredentialForCluster(clusterName, 
> alias);
>       }
> {code}
> This causes the Pac4jDispatcherFilter to regenerate the password at each 
> topology change.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to