17
17
import static com .google .common .truth .Truth .assertThat ;
18
18
import static google .registry .model .EppResourceUtils .loadByForeignKey ;
19
19
import static google .registry .testing .DatabaseHelper .createTld ;
20
+ import static google .registry .testing .DatabaseHelper .persistActiveDomain ;
21
+ import static google .registry .testing .DatabaseHelper .persistDomainWithDependentResources ;
20
22
import static google .registry .testing .DatabaseHelper .persistResource ;
21
23
import static google .registry .testing .DatabaseHelper .persistSimpleResources ;
22
24
import static google .registry .testing .FullFieldsTestEntityHelper .makeAndPersistHost ;
31
33
import com .google .gson .JsonObject ;
32
34
import google .registry .model .contact .Contact ;
33
35
import google .registry .model .domain .Domain ;
36
+ import google .registry .model .domain .GracePeriod ;
34
37
import google .registry .model .domain .Period ;
38
+ import google .registry .model .domain .rgp .GracePeriodStatus ;
39
+ import google .registry .model .eppcommon .StatusValue ;
35
40
import google .registry .model .host .Host ;
36
41
import google .registry .model .registrar .Registrar ;
37
42
import google .registry .model .reporting .HistoryEntry ;
43
48
import google .registry .request .Action ;
44
49
import google .registry .testing .FullFieldsTestEntityHelper ;
45
50
import java .util .Optional ;
51
+ import org .joda .time .DateTime ;
46
52
import org .junit .jupiter .api .BeforeEach ;
47
53
import org .junit .jupiter .api .Disabled ;
48
54
import org .junit .jupiter .api .Test ;
@@ -59,14 +65,17 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
59
65
super (RdapDomainAction .class );
60
66
}
61
67
68
+ private Contact registrantLol ;
69
+ private Host host1 ;
70
+
62
71
@ BeforeEach
63
72
void beforeEach () {
64
73
// lol
65
74
createTld ("lol" );
66
75
Registrar registrarLol = persistResource (makeRegistrar (
67
76
"evilregistrar" , "Yes Virginia <script>" , Registrar .State .ACTIVE ));
68
77
persistSimpleResources (makeRegistrarPocs (registrarLol ));
69
- Contact registrantLol =
78
+ registrantLol =
70
79
FullFieldsTestEntityHelper .makeAndPersistContact (
71
80
"5372808-ERL" ,
72
81
"Goblin Market" ,
@@ -83,7 +92,7 @@ void beforeEach() {
83
92
Contact techContactLol =
84
93
FullFieldsTestEntityHelper .makeAndPersistContact (
85
94
"5372808-TRL" ,
"The Raven" ,
"[email protected] " ,
clock .
nowUtc ().
minusYears (
3 ),
registrarLol );
86
- Host host1 = makeAndPersistHost ("ns1.cat.lol" , "1.2.3.4" , null , clock .nowUtc ().minusYears (1 ));
95
+ host1 = makeAndPersistHost ("ns1.cat.lol" , "1.2.3.4" , null , clock .nowUtc ().minusYears (1 ));
87
96
Host host2 =
88
97
makeAndPersistHost (
89
98
"ns2.cat.lol" , "bad:f00d:cafe:0:0:0:15:beef" , clock .nowUtc ().minusYears (2 ));
@@ -493,6 +502,93 @@ void testDeletedDomain_works_loggedInAsAdmin() {
493
502
assertThat (response .getStatus ()).isEqualTo (200 );
494
503
}
495
504
505
+ @ Test
506
+ void testAddGracePeriod () {
507
+ persistActiveDomainWithHost (
508
+ "addgraceperiod" , "lol" , clock .nowUtc (), clock .nowUtc ().plusYears (1 ));
509
+ assertAboutJson ()
510
+ .that (generateActualJson ("addgraceperiod.lol" ))
511
+ .isEqualTo (addBoilerplate (jsonFileBuilder ().load ("rdap_domain_add_grace_period.json" )));
512
+ }
513
+
514
+ @ Test
515
+ void testAutoRenewGracePeriod () {
516
+ persistActiveDomainWithHost (
517
+ "autorenew" , "lol" , clock .nowUtc ().minusYears (1 ).minusDays (1 ), clock .nowUtc ().minusDays (1 ));
518
+ assertAboutJson ()
519
+ .that (generateActualJson ("autorenew.lol" ))
520
+ .isEqualTo (
521
+ addBoilerplate (jsonFileBuilder ().load ("rdap_domain_auto_renew_grace_period.json" )));
522
+ }
523
+
524
+ @ Test
525
+ void testRedemptionGracePeriod () {
526
+ Domain domain = persistActiveDomain ("redemption.lol" , clock .nowUtc ().minusYears (1 ));
527
+ persistResource (
528
+ domain
529
+ .asBuilder ()
530
+ .addNameserver (host1 .createVKey ())
531
+ .setDeletionTime (clock .nowUtc ().plusDays (1 ))
532
+ .setStatusValues (ImmutableSet .of (StatusValue .PENDING_DELETE ))
533
+ .setGracePeriods (
534
+ ImmutableSet .of (
535
+ GracePeriod .createWithoutBillingEvent (
536
+ GracePeriodStatus .REDEMPTION ,
537
+ domain .getRepoId (),
538
+ clock .nowUtc ().plusDays (4 ),
539
+ "TheRegistrar" )))
540
+ .build ());
541
+ assertAboutJson ()
542
+ .that (generateActualJson ("redemption.lol" ))
543
+ .isEqualTo (
544
+ addBoilerplate (
545
+ jsonFileBuilder ().load ("rdap_domain_pending_delete_redemption_grace_period.json" )));
546
+ }
547
+
548
+ @ Test
549
+ void testRenewGracePeriod () {
550
+ Domain domain =
551
+ persistActiveDomainWithHost (
552
+ "renew" , "lol" , clock .nowUtc ().minusYears (1 ), clock .nowUtc ().plusYears (1 ));
553
+ persistResource (
554
+ domain
555
+ .asBuilder ()
556
+ .addGracePeriod (
557
+ GracePeriod .create (
558
+ GracePeriodStatus .RENEW ,
559
+ domain .getRepoId (),
560
+ clock .nowUtc ().plusDays (1 ),
561
+ "TheRegistrar" ,
562
+ null ))
563
+ .build ());
564
+ assertAboutJson ()
565
+ .that (generateActualJson ("renew.lol" ))
566
+ .isEqualTo (
567
+ addBoilerplate (jsonFileBuilder ().load ("rdap_domain_explicit_renew_grace_period.json" )));
568
+ }
569
+
570
+ @ Test
571
+ void testTransferGracePeriod () {
572
+ Domain domain =
573
+ persistActiveDomainWithHost (
574
+ "transfer" , "lol" , clock .nowUtc ().minusMonths (6 ), clock .nowUtc ().plusYears (1 ));
575
+ persistResource (
576
+ domain
577
+ .asBuilder ()
578
+ .addGracePeriod (
579
+ GracePeriod .create (
580
+ GracePeriodStatus .TRANSFER ,
581
+ domain .getRepoId (),
582
+ clock .nowUtc ().plusDays (1 ),
583
+ "TheRegistrar" ,
584
+ null ))
585
+ .build ());
586
+ assertAboutJson ()
587
+ .that (generateActualJson ("transfer.lol" ))
588
+ .isEqualTo (
589
+ addBoilerplate (jsonFileBuilder ().load ("rdap_domain_transfer_grace_period.json" )));
590
+ }
591
+
496
592
@ Test
497
593
void testMetrics () {
498
594
generateActualJson ("cat.lol" );
@@ -511,4 +607,14 @@ void testMetrics() {
511
607
.setIncompletenessWarningType (IncompletenessWarningType .COMPLETE )
512
608
.build ());
513
609
}
610
+
611
+ private Domain persistActiveDomainWithHost (
612
+ String label , String tld , DateTime creationTime , DateTime expirationTime ) {
613
+ return persistResource (
614
+ persistDomainWithDependentResources (
615
+ label , tld , registrantLol , clock .nowUtc (), creationTime , expirationTime )
616
+ .asBuilder ()
617
+ .addNameserver (host1 .createVKey ())
618
+ .build ());
619
+ }
514
620
}
0 commit comments