mirror of
https://github.com/google/nomulus
synced 2026-09-01 13:46:55 +00:00
Refactor the way that the console BE parses POST bodies (#2113)
This includes two changes: 1. Creating a base string-type adapter for use parsing to/from JSON classes that are represented as simple strings 2. Changing the object-provider methods so that the POST bodies should contain precisely the expected object(s) and nothing else. This way, it's easier for the frontend and backend to agree that, for instance, one POST endpoint might accept exactly a Registrar object, or a list of Contact objects.
This commit is contained in:
@@ -251,9 +251,7 @@ class RegistrarsActionTest {
|
||||
passcodeGenerator);
|
||||
} else {
|
||||
try {
|
||||
doReturn(
|
||||
new BufferedReader(
|
||||
new StringReader("{\"registrar\":" + registrarParamMap.toString() + "}")))
|
||||
doReturn(new BufferedReader(new StringReader(registrarParamMap.toString())))
|
||||
.when(request)
|
||||
.getReader();
|
||||
} catch (IOException e) {
|
||||
|
||||
+1
-2
@@ -238,8 +238,7 @@ class ContactActionTest {
|
||||
if (method.equals(Action.Method.GET)) {
|
||||
return new ContactAction(request, authResult, response, GSON, registrarId, Optional.empty());
|
||||
} else {
|
||||
when(request.getReader())
|
||||
.thenReturn(new BufferedReader(new StringReader("{\"contacts\":" + contacts + "}")));
|
||||
when(request.getReader()).thenReturn(new BufferedReader(new StringReader(contacts)));
|
||||
Optional<ImmutableSet<RegistrarPoc>> maybeContacts =
|
||||
RegistrarConsoleModule.provideContacts(
|
||||
GSON, RequestModule.provideJsonBody(request, GSON));
|
||||
|
||||
+3
-6
@@ -116,12 +116,9 @@ class SecurityActionTest {
|
||||
|
||||
private SecurityAction createAction(AuthResult authResult, String registrarId)
|
||||
throws IOException {
|
||||
doReturn(new BufferedReader(new StringReader("{\"registrar\":" + jsonRegistrar1 + "}")))
|
||||
.when(request)
|
||||
.getReader();
|
||||
Optional<Registrar> maybeRegistrar =
|
||||
RegistrarConsoleModule.provideRegistrar(
|
||||
GSON, RequestModule.provideJsonBody(request, GSON));
|
||||
doReturn(new BufferedReader(new StringReader(jsonRegistrar1))).when(request).getReader();
|
||||
Optional<Registrar> maybeRegistrar =
|
||||
RegistrarConsoleModule.provideRegistrar(GSON, RequestModule.provideJsonBody(request, GSON));
|
||||
return new SecurityAction(
|
||||
authResult,
|
||||
response,
|
||||
|
||||
Reference in New Issue
Block a user