@Test(expected = IllegalArgumentException.class) public void describeThrowsIfTooManyArguments() throws Exception { describeActionConfig.describeType = Arrays.asList("group", "client"); describeAction.run(); }
@Override public void run() { List<String> describeType = describeActionConfig.describeType; if (describeType == null || describeType.isEmpty()) { throw new IllegalArgumentException("Must specify a single type to describe."); } if (describeActionConfig.name == null || !validName(describeActionConfig.name)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } String firstType = describeType.get(0).toLowerCase().trim(); String name = describeActionConfig.name; switch (firstType) { case "group": try { Group group = keywhizClient.getGroupByName(name); printing.printGroupWithDetails(group); } catch (NotFoundException e) { throw new AssertionError("Group not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "client": try { Client client = keywhizClient.getClientByName(name); printing.printClientWithDetails(client); } catch (NotFoundException e) { throw new AssertionError("Client not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "secret": SanitizedSecret sanitizedSecret; try { sanitizedSecret = keywhizClient.getSanitizedSecretByName(name); printing.printSanitizedSecretWithDetails(sanitizedSecret); } catch (NotFoundException e) { throw new AssertionError("Secret not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; default: throw new IllegalArgumentException("Invalid describe type specified: " + firstType); } }
DescribeAction implements Runnable { @Override public void run() { List<String> describeType = describeActionConfig.describeType; if (describeType == null || describeType.isEmpty()) { throw new IllegalArgumentException("Must specify a single type to describe."); } if (describeActionConfig.name == null || !validName(describeActionConfig.name)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } String firstType = describeType.get(0).toLowerCase().trim(); String name = describeActionConfig.name; switch (firstType) { case "group": try { Group group = keywhizClient.getGroupByName(name); printing.printGroupWithDetails(group); } catch (NotFoundException e) { throw new AssertionError("Group not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "client": try { Client client = keywhizClient.getClientByName(name); printing.printClientWithDetails(client); } catch (NotFoundException e) { throw new AssertionError("Client not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "secret": SanitizedSecret sanitizedSecret; try { sanitizedSecret = keywhizClient.getSanitizedSecretByName(name); printing.printSanitizedSecretWithDetails(sanitizedSecret); } catch (NotFoundException e) { throw new AssertionError("Secret not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; default: throw new IllegalArgumentException("Invalid describe type specified: " + firstType); } } }
DescribeAction implements Runnable { @Override public void run() { List<String> describeType = describeActionConfig.describeType; if (describeType == null || describeType.isEmpty()) { throw new IllegalArgumentException("Must specify a single type to describe."); } if (describeActionConfig.name == null || !validName(describeActionConfig.name)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } String firstType = describeType.get(0).toLowerCase().trim(); String name = describeActionConfig.name; switch (firstType) { case "group": try { Group group = keywhizClient.getGroupByName(name); printing.printGroupWithDetails(group); } catch (NotFoundException e) { throw new AssertionError("Group not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "client": try { Client client = keywhizClient.getClientByName(name); printing.printClientWithDetails(client); } catch (NotFoundException e) { throw new AssertionError("Client not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "secret": SanitizedSecret sanitizedSecret; try { sanitizedSecret = keywhizClient.getSanitizedSecretByName(name); printing.printSanitizedSecretWithDetails(sanitizedSecret); } catch (NotFoundException e) { throw new AssertionError("Secret not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; default: throw new IllegalArgumentException("Invalid describe type specified: " + firstType); } } DescribeAction(DescribeActionConfig describeActionConfig, KeywhizClient client,
      Printing printing); }
DescribeAction implements Runnable { @Override public void run() { List<String> describeType = describeActionConfig.describeType; if (describeType == null || describeType.isEmpty()) { throw new IllegalArgumentException("Must specify a single type to describe."); } if (describeActionConfig.name == null || !validName(describeActionConfig.name)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } String firstType = describeType.get(0).toLowerCase().trim(); String name = describeActionConfig.name; switch (firstType) { case "group": try { Group group = keywhizClient.getGroupByName(name); printing.printGroupWithDetails(group); } catch (NotFoundException e) { throw new AssertionError("Group not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "client": try { Client client = keywhizClient.getClientByName(name); printing.printClientWithDetails(client); } catch (NotFoundException e) { throw new AssertionError("Client not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "secret": SanitizedSecret sanitizedSecret; try { sanitizedSecret = keywhizClient.getSanitizedSecretByName(name); printing.printSanitizedSecretWithDetails(sanitizedSecret); } catch (NotFoundException e) { throw new AssertionError("Secret not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; default: throw new IllegalArgumentException("Invalid describe type specified: " + firstType); } } DescribeAction(DescribeActionConfig describeActionConfig, KeywhizClient client,
      Printing printing); @Override void run(); }
DescribeAction implements Runnable { @Override public void run() { List<String> describeType = describeActionConfig.describeType; if (describeType == null || describeType.isEmpty()) { throw new IllegalArgumentException("Must specify a single type to describe."); } if (describeActionConfig.name == null || !validName(describeActionConfig.name)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } String firstType = describeType.get(0).toLowerCase().trim(); String name = describeActionConfig.name; switch (firstType) { case "group": try { Group group = keywhizClient.getGroupByName(name); printing.printGroupWithDetails(group); } catch (NotFoundException e) { throw new AssertionError("Group not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "client": try { Client client = keywhizClient.getClientByName(name); printing.printClientWithDetails(client); } catch (NotFoundException e) { throw new AssertionError("Client not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; case "secret": SanitizedSecret sanitizedSecret; try { sanitizedSecret = keywhizClient.getSanitizedSecretByName(name); printing.printSanitizedSecretWithDetails(sanitizedSecret); } catch (NotFoundException e) { throw new AssertionError("Secret not found."); } catch (IOException e) { throw Throwables.propagate(e); } break; default: throw new IllegalArgumentException("Invalid describe type specified: " + firstType); } } DescribeAction(DescribeActionConfig describeActionConfig, KeywhizClient client,
      Printing printing); @Override void run();  }