mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 00:42:12 +02:00
Make logged response in NordnUploadAction intelligible
Right now it's logging the raw bytes, which look like: response data: [65, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 32, 114, 101, 113, 117, 105, 114, 101, 100] We'd rather convert it to ASCII characters (what the NORDN service uses) before logging it, so that it'd instead look like: response data: Authorization required ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=231998658
This commit is contained in:
parent
c5ad30f49d
commit
f01ded3fa7
2 changed files with 19 additions and 3 deletions
|
@ -28,6 +28,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||
import static google.registry.util.UrlFetchUtils.getHeaderFirst;
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
|
@ -112,6 +113,7 @@ public class NordnUploadActionTest {
|
|||
public void before() throws Exception {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
when(fetchService.fetch(any(HTTPRequest.class))).thenReturn(httpResponse);
|
||||
when(httpResponse.getContent()).thenReturn("Success".getBytes(US_ASCII));
|
||||
when(httpResponse.getResponseCode()).thenReturn(SC_ACCEPTED);
|
||||
when(httpResponse.getHeadersUncombined())
|
||||
.thenReturn(ImmutableList.of(new HTTPHeader(LOCATION, "http://trololol")));
|
||||
|
@ -240,6 +242,15 @@ public class NordnUploadActionTest {
|
|||
assertThat(new String(getCapturedHttpRequest().getPayload(), UTF_8)).contains(SUNRISE_CSV);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_noResponseContent_stillWorksNormally() throws Exception {
|
||||
// Returning null only affects logging.
|
||||
when(httpResponse.getContent()).thenReturn(null);
|
||||
persistSunriseModeDomain();
|
||||
action.run();
|
||||
assertThat(new String(getCapturedHttpRequest().getPayload(), UTF_8)).contains(SUNRISE_CSV);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_sunriseMode_verifyTaskGetsEnqueuedWithSunriseCsv() {
|
||||
persistSunriseModeDomain();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue