add `@Produces` annotations to a few methods in DeviceController
This commit is contained in:
parent
c2317e8493
commit
1ab6bff54e
|
@ -101,6 +101,7 @@ public class DeviceController {
|
||||||
|
|
||||||
@Timed
|
@Timed
|
||||||
@DELETE
|
@DELETE
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("/{device_id}")
|
@Path("/{device_id}")
|
||||||
@ChangesDeviceEnabledState
|
@ChangesDeviceEnabledState
|
||||||
public void removeDevice(@Auth AuthenticatedAccount auth, @PathParam("device_id") long deviceId) {
|
public void removeDevice(@Auth AuthenticatedAccount auth, @PathParam("device_id") long deviceId) {
|
||||||
|
@ -217,6 +218,7 @@ public class DeviceController {
|
||||||
|
|
||||||
@Timed
|
@Timed
|
||||||
@PUT
|
@PUT
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("/unauthenticated_delivery")
|
@Path("/unauthenticated_delivery")
|
||||||
public void setUnauthenticatedDelivery(@Auth AuthenticatedAccount auth) {
|
public void setUnauthenticatedDelivery(@Auth AuthenticatedAccount auth) {
|
||||||
assert (auth.getAuthenticatedDevice() != null);
|
assert (auth.getAuthenticatedDevice() != null);
|
||||||
|
@ -225,6 +227,7 @@ public class DeviceController {
|
||||||
|
|
||||||
@Timed
|
@Timed
|
||||||
@PUT
|
@PUT
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("/capabilities")
|
@Path("/capabilities")
|
||||||
public void setCapabilities(@Auth AuthenticatedAccount auth, @NotNull @Valid DeviceCapabilities capabilities) {
|
public void setCapabilities(@Auth AuthenticatedAccount auth, @NotNull @Valid DeviceCapabilities capabilities) {
|
||||||
assert (auth.getAuthenticatedDevice() != null);
|
assert (auth.getAuthenticatedDevice() != null);
|
||||||
|
|
|
@ -758,6 +758,32 @@ class DeviceControllerTest {
|
||||||
assertThat(response.getStatus()).isEqualTo(200);
|
assertThat(response.getStatus()).isEqualTo(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void putCapabilitiesSuccessTest() {
|
||||||
|
final DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true);
|
||||||
|
final Response response = resources
|
||||||
|
.getJerseyTest()
|
||||||
|
.target("/v1/devices/capabilities")
|
||||||
|
.request()
|
||||||
|
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||||
|
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||||
|
.put(Entity.entity(deviceCapabilities, MediaType.APPLICATION_JSON_TYPE));
|
||||||
|
assertThat(response.getStatus()).isEqualTo(204);
|
||||||
|
assertThat(response.hasEntity()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void putCapabilitiesFailureTest() {
|
||||||
|
final Response response = resources
|
||||||
|
.getJerseyTest()
|
||||||
|
.target("/v1/devices/capabilities")
|
||||||
|
.request()
|
||||||
|
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||||
|
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||||
|
.put(Entity.json(""));
|
||||||
|
assertThat(response.getStatus()).isEqualTo(422);
|
||||||
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(booleans = {true, false})
|
@ValueSource(booleans = {true, false})
|
||||||
void deviceDowngradePaymentActivationTest(boolean paymentActivation) {
|
void deviceDowngradePaymentActivationTest(boolean paymentActivation) {
|
||||||
|
@ -791,6 +817,7 @@ class DeviceControllerTest {
|
||||||
.delete();
|
.delete();
|
||||||
|
|
||||||
assertThat(response.getStatus()).isEqualTo(204);
|
assertThat(response.getStatus()).isEqualTo(204);
|
||||||
|
assertThat(response.hasEntity()).isFalse();
|
||||||
|
|
||||||
verify(messagesManager, times(2)).clear(AuthHelper.VALID_UUID, deviceId);
|
verify(messagesManager, times(2)).clear(AuthHelper.VALID_UUID, deviceId);
|
||||||
verify(accountsManager, times(1)).update(eq(AuthHelper.VALID_ACCOUNT), any());
|
verify(accountsManager, times(1)).update(eq(AuthHelper.VALID_ACCOUNT), any());
|
||||||
|
|
Loading…
Reference in New Issue