@Test (expected = NotFoundException.class) public void listSecretVersionsThrowsException() { when(secretDAO.getSecretVersionsByName(eq("name2"), anyInt(), anyInt())).thenReturn( Optional.empty()); resource.secretVersions(user, "name2", 0, 10); }
@Timed @ExceptionMetered @GET @Path("versions/{name}") @Produces(APPLICATION_JSON) public List<SanitizedSecret> secretVersions(@Auth User user, @PathParam("name") String name, @QueryParam("versionIdx") int versionIdx, @QueryParam("numVersions") int numVersions) { logger.info("User '{}' listing {} versions starting at index {} for secret '{}'.", user, numVersions, versionIdx, name); ImmutableList<SanitizedSecret> versions = secretDAOReadOnly.getSecretVersionsByName(name, versionIdx, numVersions) .orElseThrow(NotFoundException::new); return versions; }
SecretsResource { @Timed @ExceptionMetered @GET @Path("versions/{name}") @Produces(APPLICATION_JSON) public List<SanitizedSecret> secretVersions(@Auth User user, @PathParam("name") String name, @QueryParam("versionIdx") int versionIdx, @QueryParam("numVersions") int numVersions) { logger.info("User '{}' listing {} versions starting at index {} for secret '{}'.", user, numVersions, versionIdx, name); ImmutableList<SanitizedSecret> versions = secretDAOReadOnly.getSecretVersionsByName(name, versionIdx, numVersions) .orElseThrow(NotFoundException::new); return versions; } }
SecretsResource { @Timed @ExceptionMetered @GET @Path("versions/{name}") @Produces(APPLICATION_JSON) public List<SanitizedSecret> secretVersions(@Auth User user, @PathParam("name") String name, @QueryParam("versionIdx") int versionIdx, @QueryParam("numVersions") int numVersions) { logger.info("User '{}' listing {} versions starting at index {} for secret '{}'.", user, numVersions, versionIdx, name); ImmutableList<SanitizedSecret> versions = secretDAOReadOnly.getSecretVersionsByName(name, versionIdx, numVersions) .orElseThrow(NotFoundException::new); return versions; } @SuppressWarnings("unused") @Inject  SecretsResource(SecretController secretController, AclDAOFactory aclDAOFactory,
      SecretDAOFactory secretDAOFactory, AuditLog auditLog); @VisibleForTesting  SecretsResource(SecretController secretController, AclDAO aclDAOReadOnly,
      SecretDAO secretDAOReadWrite, AuditLog auditLog); }
SecretsResource { @Timed @ExceptionMetered @GET @Path("versions/{name}") @Produces(APPLICATION_JSON) public List<SanitizedSecret> secretVersions(@Auth User user, @PathParam("name") String name, @QueryParam("versionIdx") int versionIdx, @QueryParam("numVersions") int numVersions) { logger.info("User '{}' listing {} versions starting at index {} for secret '{}'.", user, numVersions, versionIdx, name); ImmutableList<SanitizedSecret> versions = secretDAOReadOnly.getSecretVersionsByName(name, versionIdx, numVersions) .orElseThrow(NotFoundException::new); return versions; } @SuppressWarnings("unused") @Inject  SecretsResource(SecretController secretController, AclDAOFactory aclDAOFactory,
      SecretDAOFactory secretDAOFactory, AuditLog auditLog); @VisibleForTesting  SecretsResource(SecretController secretController, AclDAO aclDAOReadOnly,
      SecretDAO secretDAOReadWrite, AuditLog auditLog); @Timed @ExceptionMetered @GET Response findSecrets(@Auth User user, @DefaultValue("") @QueryParam("name") String name,
      @DefaultValue("") @QueryParam("nameOnly") String nameOnly, @QueryParam("idx") Integer idx,
      @QueryParam("num") Integer num,
      @DefaultValue("true") @QueryParam("newestFirst") Boolean newestFirst); @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response createSecret(@Auth User user, @Valid CreateSecretRequestV2 request); @Path("{name}") @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response createOrUpdateSecret(@Auth User user, @PathParam("name") String secretName,
      @Valid CreateOrUpdateSecretRequestV2 request); @Path("{name}/partialupdate") @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response partialUpdateSecret(@Auth User user, @PathParam("name") String secretName, @Valid
      PartialUpdateSecretRequestV2 request); @Path("{secretId}") @Timed @ExceptionMetered @GET SecretDetailResponse retrieveSecret(@Auth User user,
      @PathParam("secretId") LongParam secretId); @Timed @ExceptionMetered @GET @Path("versions/{name}") @Produces(APPLICATION_JSON) List<SanitizedSecret> secretVersions(@Auth User user,
      @PathParam("name") String name, @QueryParam("versionIdx") int versionIdx,
      @QueryParam("numVersions") int numVersions); @Path("rollback/{secretName}/{versionId}") @Timed @ExceptionMetered @POST Response resetSecretVersion(@Auth User user, @PathParam("secretName") String secretName,
      @PathParam("versionId") LongParam versionId); @Path("{secretId}") @Timed @ExceptionMetered @DELETE Response deleteSecret(@Auth User user, @PathParam("secretId") LongParam secretId); }
SecretsResource { @Timed @ExceptionMetered @GET @Path("versions/{name}") @Produces(APPLICATION_JSON) public List<SanitizedSecret> secretVersions(@Auth User user, @PathParam("name") String name, @QueryParam("versionIdx") int versionIdx, @QueryParam("numVersions") int numVersions) { logger.info("User '{}' listing {} versions starting at index {} for secret '{}'.", user, numVersions, versionIdx, name); ImmutableList<SanitizedSecret> versions = secretDAOReadOnly.getSecretVersionsByName(name, versionIdx, numVersions) .orElseThrow(NotFoundException::new); return versions; } @SuppressWarnings("unused") @Inject  SecretsResource(SecretController secretController, AclDAOFactory aclDAOFactory,
      SecretDAOFactory secretDAOFactory, AuditLog auditLog); @VisibleForTesting  SecretsResource(SecretController secretController, AclDAO aclDAOReadOnly,
      SecretDAO secretDAOReadWrite, AuditLog auditLog); @Timed @ExceptionMetered @GET Response findSecrets(@Auth User user, @DefaultValue("") @QueryParam("name") String name,
      @DefaultValue("") @QueryParam("nameOnly") String nameOnly, @QueryParam("idx") Integer idx,
      @QueryParam("num") Integer num,
      @DefaultValue("true") @QueryParam("newestFirst") Boolean newestFirst); @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response createSecret(@Auth User user, @Valid CreateSecretRequestV2 request); @Path("{name}") @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response createOrUpdateSecret(@Auth User user, @PathParam("name") String secretName,
      @Valid CreateOrUpdateSecretRequestV2 request); @Path("{name}/partialupdate") @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response partialUpdateSecret(@Auth User user, @PathParam("name") String secretName, @Valid
      PartialUpdateSecretRequestV2 request); @Path("{secretId}") @Timed @ExceptionMetered @GET SecretDetailResponse retrieveSecret(@Auth User user,
      @PathParam("secretId") LongParam secretId); @Timed @ExceptionMetered @GET @Path("versions/{name}") @Produces(APPLICATION_JSON) List<SanitizedSecret> secretVersions(@Auth User user,
      @PathParam("name") String name, @QueryParam("versionIdx") int versionIdx,
      @QueryParam("numVersions") int numVersions); @Path("rollback/{secretName}/{versionId}") @Timed @ExceptionMetered @POST Response resetSecretVersion(@Auth User user, @PathParam("secretName") String secretName,
      @PathParam("versionId") LongParam versionId); @Path("{secretId}") @Timed @ExceptionMetered @DELETE Response deleteSecret(@Auth User user, @PathParam("secretId") LongParam secretId);  }