401 instead of 403 on wrong backup auth credential type
This commit is contained in:
parent
c1e870d8f5
commit
fc0a7b7657
|
@ -649,7 +649,7 @@ public class BackupManager {
|
||||||
*
|
*
|
||||||
* @param backupUser The backup user to check
|
* @param backupUser The backup user to check
|
||||||
* @param credentialType The credential type to require
|
* @param credentialType The credential type to require
|
||||||
* @throws {@link Status#PERMISSION_DENIED} error if the backup user is not authenticated with the given
|
* @throws {@link Status#UNAUTHENTICATED} error if the backup user is not authenticated with the given
|
||||||
* {@code credentialType}
|
* {@code credentialType}
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@ -659,8 +659,8 @@ public class BackupManager {
|
||||||
FAILURE_REASON_TAG_NAME, "credential_type")
|
FAILURE_REASON_TAG_NAME, "credential_type")
|
||||||
.increment();
|
.increment();
|
||||||
|
|
||||||
throw Status.PERMISSION_DENIED
|
throw Status.UNAUTHENTICATED
|
||||||
.withDescription("credential does not support the requested operation")
|
.withDescription("wrong credential type for the requested operation")
|
||||||
.asRuntimeException();
|
.asRuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class BackupManagerTest {
|
||||||
.isThrownBy(checkCredentialType)
|
.isThrownBy(checkCredentialType)
|
||||||
.extracting(StatusRuntimeException::getStatus)
|
.extracting(StatusRuntimeException::getStatus)
|
||||||
.extracting(Status::getCode)
|
.extracting(Status::getCode)
|
||||||
.isEqualTo(Status.Code.PERMISSION_DENIED);
|
.isEqualTo(Status.Code.UNAUTHENTICATED);
|
||||||
} else {
|
} else {
|
||||||
assertThatNoException().isThrownBy(checkCredentialType);
|
assertThatNoException().isThrownBy(checkCredentialType);
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ public class BackupManagerTest {
|
||||||
|
|
||||||
assertThatExceptionOfType(StatusRuntimeException.class)
|
assertThatExceptionOfType(StatusRuntimeException.class)
|
||||||
.isThrownBy(() -> backupManager.createMessageBackupUploadDescriptor(backupUser).join())
|
.isThrownBy(() -> backupManager.createMessageBackupUploadDescriptor(backupUser).join())
|
||||||
.matches(exception -> exception.getStatus().getCode() == Status.PERMISSION_DENIED.getCode());
|
.matches(exception -> exception.getStatus().getCode() == Status.UNAUTHENTICATED.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -245,7 +245,7 @@ public class BackupManagerTest {
|
||||||
.isThrownBy(() -> backupManager.createTemporaryAttachmentUploadDescriptor(backupUser))
|
.isThrownBy(() -> backupManager.createTemporaryAttachmentUploadDescriptor(backupUser))
|
||||||
.extracting(StatusRuntimeException::getStatus)
|
.extracting(StatusRuntimeException::getStatus)
|
||||||
.extracting(Status::getCode)
|
.extracting(Status::getCode)
|
||||||
.isEqualTo(Status.Code.PERMISSION_DENIED);
|
.isEqualTo(Status.Code.UNAUTHENTICATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
@ -502,7 +502,7 @@ public class BackupManagerTest {
|
||||||
.isThrownBy(() -> copy(backupUser))
|
.isThrownBy(() -> copy(backupUser))
|
||||||
.extracting(StatusRuntimeException::getStatus)
|
.extracting(StatusRuntimeException::getStatus)
|
||||||
.extracting(Status::getCode)
|
.extracting(Status::getCode)
|
||||||
.isEqualTo(Status.Code.PERMISSION_DENIED);
|
.isEqualTo(Status.Code.UNAUTHENTICATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -675,7 +675,7 @@ public class BackupManagerTest {
|
||||||
assertThatThrownBy(() ->
|
assertThatThrownBy(() ->
|
||||||
backupManager.deleteMedia(backupUser, List.of(new BackupManager.StorageDescriptor(5, mediaId))).then().block())
|
backupManager.deleteMedia(backupUser, List.of(new BackupManager.StorageDescriptor(5, mediaId))).then().block())
|
||||||
.isInstanceOf(StatusRuntimeException.class)
|
.isInstanceOf(StatusRuntimeException.class)
|
||||||
.matches(e -> ((StatusRuntimeException) e).getStatus().getCode() == Status.PERMISSION_DENIED.getCode());
|
.matches(e -> ((StatusRuntimeException) e).getStatus().getCode() == Status.UNAUTHENTICATED.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue