@Test public void updateWithMetadata() throws Exception { updateActionConfig.name = secret.getDisplayName(); updateActionConfig.description = "metadata test"; updateActionConfig.json = "{\"owner\":\"example-name\", \"group\":\"example-group\"}"; updateActionConfig.contentProvided = true; byte[] content = base64Decoder.decode(secret.getSecret()); updateAction.stream = new ByteArrayInputStream(content); when(keywhizClient.getSanitizedSecretByName(secret.getName())) .thenThrow(new NotFoundException()); when(keywhizClient.updateSecret(secret.getName(), true, "metadata test", true, content, true, updateActionConfig.getMetadata(Jackson.newObjectMapper()), false, 0)) .thenReturn(secretDetailResponse); updateAction.run(); verify(keywhizClient, times(1)).updateSecret(secret.getName(), true, "metadata test", true, content, true, updateActionConfig.getMetadata(Jackson.newObjectMapper()), false, 0); }
@Override public void run() { String secretName = config.name; if (secretName == null || !validName(secretName)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } byte[] content = {}; if (config.contentProvided) { content = readSecretContent(); if (content.length == 0) { throw new IllegalArgumentException("Secret content must be provided if --content flag is present; check inputs"); } } partialUpdateSecret(secretName, content, config); if (!config.contentProvided) { try { InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); if (reader.ready()) { System.out.println("\nWarning: Specify the --content flag to update a secret's content."); System.out.println("The secret has not been updated with any provided content."); } } catch (IOException e) { logger.warn("Unexpected error trying to create an InputStreamReader for stdin: '{}'", e.getMessage()); } } }
UpdateAction implements Runnable { @Override public void run() { String secretName = config.name; if (secretName == null || !validName(secretName)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } byte[] content = {}; if (config.contentProvided) { content = readSecretContent(); if (content.length == 0) { throw new IllegalArgumentException("Secret content must be provided if --content flag is present; check inputs"); } } partialUpdateSecret(secretName, content, config); if (!config.contentProvided) { try { InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); if (reader.ready()) { System.out.println("\nWarning: Specify the --content flag to update a secret's content."); System.out.println("The secret has not been updated with any provided content."); } } catch (IOException e) { logger.warn("Unexpected error trying to create an InputStreamReader for stdin: '{}'", e.getMessage()); } } } }
UpdateAction implements Runnable { @Override public void run() { String secretName = config.name; if (secretName == null || !validName(secretName)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } byte[] content = {}; if (config.contentProvided) { content = readSecretContent(); if (content.length == 0) { throw new IllegalArgumentException("Secret content must be provided if --content flag is present; check inputs"); } } partialUpdateSecret(secretName, content, config); if (!config.contentProvided) { try { InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); if (reader.ready()) { System.out.println("\nWarning: Specify the --content flag to update a secret's content."); System.out.println("The secret has not been updated with any provided content."); } } catch (IOException e) { logger.warn("Unexpected error trying to create an InputStreamReader for stdin: '{}'", e.getMessage()); } } } UpdateAction(UpdateActionConfig config, KeywhizClient client,
      ObjectMapper mapper); }
UpdateAction implements Runnable { @Override public void run() { String secretName = config.name; if (secretName == null || !validName(secretName)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } byte[] content = {}; if (config.contentProvided) { content = readSecretContent(); if (content.length == 0) { throw new IllegalArgumentException("Secret content must be provided if --content flag is present; check inputs"); } } partialUpdateSecret(secretName, content, config); if (!config.contentProvided) { try { InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); if (reader.ready()) { System.out.println("\nWarning: Specify the --content flag to update a secret's content."); System.out.println("The secret has not been updated with any provided content."); } } catch (IOException e) { logger.warn("Unexpected error trying to create an InputStreamReader for stdin: '{}'", e.getMessage()); } } } UpdateAction(UpdateActionConfig config, KeywhizClient client,
      ObjectMapper mapper); @Override void run(); }
UpdateAction implements Runnable { @Override public void run() { String secretName = config.name; if (secretName == null || !validName(secretName)) { throw new IllegalArgumentException(format("Invalid name, must match %s", VALID_NAME_PATTERN)); } byte[] content = {}; if (config.contentProvided) { content = readSecretContent(); if (content.length == 0) { throw new IllegalArgumentException("Secret content must be provided if --content flag is present; check inputs"); } } partialUpdateSecret(secretName, content, config); if (!config.contentProvided) { try { InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); if (reader.ready()) { System.out.println("\nWarning: Specify the --content flag to update a secret's content."); System.out.println("The secret has not been updated with any provided content."); } } catch (IOException e) { logger.warn("Unexpected error trying to create an InputStreamReader for stdin: '{}'", e.getMessage()); } } } UpdateAction(UpdateActionConfig config, KeywhizClient client,
      ObjectMapper mapper); @Override void run();  }