Skip to content

Commit

Permalink
WFCORE-5247 IllegalArgumentException and CLI crash with read-attribut…
Browse files Browse the repository at this point in the history
…e in /system-property
  • Loading branch information
parsharma committed Jan 29, 2021
1 parent 7617b8a commit 71b912e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Expand Up @@ -116,8 +116,12 @@ public boolean canAppearNext(CommandContext ctx) throws CommandFormatException {
op.get(Util.ADDRESS).setEmptyList();
} else {
final ModelNode addrNode = op.get(Util.ADDRESS);
for(OperationRequestAddress.Node node : address) {
addrNode.add(node.getType(), node.getName());
for (OperationRequestAddress.Node node : address) {
if (!(node.getName() == null)) {
addrNode.add(node.getType(), node.getName());
} else {
addrNode.add(node.getType(), "*");
}
}
}

Expand Down Expand Up @@ -219,6 +223,7 @@ public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFo
return req;
}

@Override
protected void handleResponse(CommandContext ctx, ModelNode response, boolean composite) throws CommandFormatException {
if (!Util.isSuccess(response)) {
throw new CommandFormatException(Util.getFailureDescription(response));
Expand Down
Expand Up @@ -118,6 +118,36 @@ public void complexOperationWithObjectAsAttributeTest() {
assertEquals(candidates.toString(), Arrays.asList(","), candidates);
}
}
/**
* Checks CLI completion for "read-attribute " command
*/
@Test
public void readAttributeWithSpaceTest() {
for (List<String> candidates : getCandidatesLists("read-attribute ", null)) {
assertTrue(candidates.contains("--resolve-expressions"));
assertTrue(candidates.contains("management-major-version"));
assertFalse(candidates.contains("--admin-only"));
}
}
/**
* Checks CLI completion for "read-a" command
*/
@Test
public void readAttributeWithUnfinishedCmdTest() {
for (List<String> candidates : getCandidatesLists("read-a", true)) {
assertTrue(candidates.contains("read-attribute"));
}
}
/**
* Checks CLI completion for "read-attribute --" command
*/
@Test
public void readAttributeWithUnfinishedArgumentTest() {
for (List<String> candidates : getCandidatesLists("read-attribute --", false)) {
assertTrue(candidates.contains("--resolve-expressions"));
assertTrue(candidates.contains("--verbose"));
}
}

/**
* Checks CLI completion for "help" command
Expand Down

0 comments on commit 71b912e

Please sign in to comment.