Skip to content

Commit

Permalink
Deprecate permissions fields on requests.
Browse files Browse the repository at this point in the history
Fixes #45
  • Loading branch information
scottfrederick committed Oct 24, 2018
1 parent 2d302b8 commit 1504e64
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.credhub.support;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.credhub.core.permission.CredHubPermissionOperations;
import org.springframework.credhub.support.permissions.CredentialPermission;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -206,6 +207,9 @@ public B overwrite(boolean overwrite) {
* Sets a value indicating the action CredHub should take when a credential being written
* or generated already exists.
*
* As of CredHub 2.0, this value must not be set on write requests (write requests always
* overwrite the credential that already exists) but may be set on generate requests.
*
* @param mode the {@link WriteMode} to use when a credential exists
* @return the builder
*/
Expand All @@ -218,9 +222,10 @@ public B mode(WriteMode mode) {
* Add an {@link CredentialPermission} to the permissions that will be assigned to the
* credential.
*
* @param permission a {@link CredentialPermission} to assign to the
* credential
* @param permission a {@link CredentialPermission} to assign to the credential
* @return the builder
* @deprecated as of CredHub 2.0, use {@link CredHubPermissionOperations} to assign
* permissions to a credential after it is created
*/
public B permission(CredentialPermission permission) {
targetObj.getAdditionalPermissions().add(permission);
Expand All @@ -234,6 +239,8 @@ public B permission(CredentialPermission permission) {
* @param permissions a collection of {@link CredentialPermission}s to
* assign to the credential
* @return the builder
* @deprecated as of CredHub 2.0, use {@link CredHubPermissionOperations} to assign
* permissions to a credential after it is created
*/
public B permissions(Collection<? extends CredentialPermission> permissions) {
targetObj.getAdditionalPermissions().addAll(permissions);
Expand All @@ -247,6 +254,8 @@ public B permissions(Collection<? extends CredentialPermission> permissions) {
* @param permissions a collection of {@link CredentialPermission}s to
* assign to the credential
* @return the builder
* @deprecated as of CredHub 2.0, use {@link CredHubPermissionOperations} to assign
* permissions to a credential after it is created
*/
public B permissions(CredentialPermission... permissions) {
targetObj.getAdditionalPermissions().addAll(Arrays.asList(permissions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public abstract class CredHubRequestUnitTestsBase {
protected CredHubRequestBuilder requestBuilder;

@Test
@SuppressWarnings("deprecation")
public void serializationWithOnePermission() {
requestBuilder
.permission(CredentialPermission.builder()
Expand All @@ -50,7 +51,7 @@ public void serializationWithOnePermission() {
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "deprecation"})
public void serializationWithThreePermissions() {
requestBuilder
.permission(CredentialPermission.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;

public class CertificateIntegrationTests extends CredHubIntegrationTests {
private static final SimpleCredentialName CREDENTIAL_NAME =
Expand All @@ -46,6 +47,8 @@ public class CertificateIntegrationTests extends CredHubIntegrationTests {

@Before
public void setUp() {
assumeTrue(serverApiIsV2());

credentials = operations.credentials();
certificates = operations.certificates();

Expand Down

0 comments on commit 1504e64

Please sign in to comment.