mirror of
https://github.com/google/nomulus
synced 2026-02-09 14:30:33 +00:00
Fix bug that was incorrectly assuming Cursor would always exist (#1088)
* Fix bug that was incorrectly assuming Cursor would always exist In fact, the Cursor entity does not always exist (i.e. if an upload has never previously been done on this TLD, i.e. it's a new TLD), and the code needs to be resilient to its non-existence. This bug was introduced in #1044.
This commit is contained in:
@@ -19,6 +19,7 @@ import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.common.Cursor.CursorType.RDE_REPORT;
|
||||
import static google.registry.model.common.Cursor.CursorType.RDE_UPLOAD;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
@@ -162,6 +163,19 @@ public class RdeReportActionTest {
|
||||
assertThat(report.getWatermark()).isEqualTo(DateTime.parse("2010-10-17T00:00:00Z"));
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testRunWithLock_nonexistentCursor_throws204() {
|
||||
tm().transact(() -> tm().delete(Cursor.createVKey(RDE_UPLOAD, "test")));
|
||||
NoContentException thrown =
|
||||
assertThrows(
|
||||
NoContentException.class, () -> createAction().runWithLock(loadRdeReportCursor()));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
"Waiting on RdeUploadAction for TLD test to send 2006-06-06T00:00:00.000Z report; last"
|
||||
+ " upload completion was at 1970-01-01T00:00:00.000Z");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testRunWithLock_uploadNotFinished_throws204() {
|
||||
persistResource(
|
||||
|
||||
@@ -318,6 +318,23 @@ public class RdeUploadActionTest {
|
||||
assertThat(stderr).contains("rde-unittest@registry.test");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testRunWithLock_nonexistentCursor_throws204() throws Exception {
|
||||
int port = sftpd.serve("user", "password", folder);
|
||||
URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
|
||||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||
RdeUploadAction action = createAction(uploadUrl);
|
||||
NoContentException thrown =
|
||||
assertThrows(NoContentException.class, () -> action.runWithLock(uploadCursor));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
"Waiting on RdeStagingAction for TLD tld to send 2010-10-17T00:00:00.000Z upload; last"
|
||||
+ " RDE staging completion was at 1970-01-01T00:00:00.000Z");
|
||||
assertNoTasksEnqueued("rde-upload");
|
||||
assertThat(folder.list()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testRunWithLock_stagingNotFinished_throws204() {
|
||||
URI url = URI.create("sftp://user:password@localhost:32323/");
|
||||
|
||||
Reference in New Issue
Block a user