Skip to content

Commit 2ee9413

Browse files
authored
Only validate user credentials if there are patches involved. (#410)
1 parent 2c5284e commit 2ee9413

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonPatchingOptions.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ void initializeOptions() throws IOException, InvalidCredentialException, Invalid
5757
super.initializeOptions();
5858
password = Utils.getPasswordFromInputs(passwordStr, passwordFile, passwordEnv);
5959

60-
// if userid or password is provided, validate the pair of provided values
61-
if ((userId != null || password != null) && !AruUtil.rest().checkCredentials(userId, password)) {
62-
throw new InvalidCredentialException();
63-
}
60+
if (applyingPatches()) {
61+
// if userid or password is provided, validate the pair of provided values
62+
if ((userId != null || password != null) && !AruUtil.rest().checkCredentials(userId, password)) {
63+
throw new InvalidCredentialException();
64+
}
6465

65-
Utils.validatePatchIds(patches, false);
66+
Utils.validatePatchIds(patches, false);
67+
}
6668
}
6769

6870
/**

imagetool/src/test/java/com/oracle/weblogic/imagetool/cli/menu/CommonPatchingOptions2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void tearDown() throws NoSuchFieldException, IllegalAccessException {
3737
void noPassword() {
3838
// This test requires that ARUUtil instance NOT be overridden
3939
CreateImage createImage = new CreateImage();
40-
new CommandLine(createImage).parseArgs("--tag", "tag:1", "--user", "derek");
40+
new CommandLine(createImage).parseArgs("--tag", "tag:1", "--user", "derek", "--patches", "12345678");
4141
assertThrows(InvalidCredentialException.class, createImage::initializeOptions);
4242
}
4343

0 commit comments

Comments
 (0)