Skip to content

Commit aa16ea9

Browse files
committed
Addressing comments
1 parent 0772576 commit aa16ea9

File tree

2 files changed

+163
-2
lines changed

2 files changed

+163
-2
lines changed

core/src/main/java/google/registry/tmch/RstTmchUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static Optional<ClaimsList> getClaimsList(RstEnvironment rstEnvironment)
9797
} catch (IOException e) {
9898
// Do not throw.
9999
logger.atSevere().withCause(e).log(
100-
"Could not load Claims list for %s in Sandbox.", rstEnvironment);
100+
"Could not load Claims list %s for %s in Sandbox.", resourceName, rstEnvironment);
101101
return Optional.empty();
102102
}
103103
}
@@ -113,7 +113,7 @@ private static Optional<SignedMarkRevocationList> getSmdrList(RstEnvironment rst
113113
} catch (IOException e) {
114114
// Do not throw.
115115
logger.atSevere().withCause(e).log(
116-
"Could not load Claims list for %s in Sandbox.", rstEnvironment);
116+
"Could not load SMDR list %s for %s in Sandbox.", resourceName, rstEnvironment);
117117
return Optional.empty();
118118
}
119119
}
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// Copyright 2025 The Nomulus Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package google.registry.tmch;
16+
17+
import static com.google.common.truth.Truth.assertThat;
18+
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
19+
import static google.registry.util.RegistryEnvironment.PRODUCTION;
20+
import static google.registry.util.RegistryEnvironment.SANDBOX;
21+
import static org.joda.time.DateTime.now;
22+
import static org.joda.time.DateTimeZone.UTC;
23+
24+
import com.google.common.base.Splitter;
25+
import google.registry.model.smd.SignedMarkRevocationList;
26+
import google.registry.model.smd.SignedMarkRevocationListDao;
27+
import google.registry.model.tmch.ClaimsListDao;
28+
import google.registry.persistence.transaction.JpaTestExtensions;
29+
import google.registry.testing.FakeClock;
30+
import google.registry.util.RegistryEnvironment;
31+
import java.util.stream.Stream;
32+
import org.junit.jupiter.api.BeforeEach;
33+
import org.junit.jupiter.api.extension.RegisterExtension;
34+
import org.junit.jupiter.params.ParameterizedTest;
35+
import org.junit.jupiter.params.provider.Arguments;
36+
import org.junit.jupiter.params.provider.MethodSource;
37+
38+
public class RstTmchUtilsIntTest {
39+
private final FakeClock clock = new FakeClock();
40+
41+
@RegisterExtension
42+
final JpaTestExtensions.JpaIntegrationTestExtension jpa =
43+
new JpaTestExtensions.Builder().withClock(clock).buildIntegrationTestExtension();
44+
45+
private static final String TMCH_CLAIM_LABEL = "tmch";
46+
// RST label found in *.rst.dnl.csv resources. Currently both files are identical
47+
private static final String RST_CLAIM_LABEL = "test--validate";
48+
49+
private static final String TMCH_SMD_ID = "tmch";
50+
// RST label found in *.rst.smdrl.csv resources. Currently both files are identical
51+
private static final String RST_SMD_ID = "0000001761385117375880-65535";
52+
53+
private static final String TMCH_DNL =
54+
"""
55+
1,2024-09-13T02:21:12.0Z
56+
DNL,lookup-key,insertion-datetime
57+
LABEL,2024091300/6/a/b/arJyPPf2CK7f21bVGne0qMgW0000000001,2024-09-13T02:21:12.0Z
58+
"""
59+
.replace("LABEL", TMCH_CLAIM_LABEL);
60+
61+
private static final String TMCH_SMDRL =
62+
"""
63+
1,2022-11-22T01:49:36.9Z
64+
smd-id,insertion-datetime
65+
ID,2013-07-15T00:00:00.0Z
66+
"""
67+
.replace("ID", TMCH_SMD_ID);
68+
69+
@BeforeEach
70+
void setup() throws Exception {
71+
Splitter lineSplitter = Splitter.on("\n").omitEmptyStrings().trimResults();
72+
tm().transact(
73+
() -> ClaimsListDao.save(ClaimsListParser.parse(lineSplitter.splitToList(TMCH_DNL))));
74+
tm().transact(
75+
() ->
76+
SignedMarkRevocationListDao.save(
77+
SmdrlCsvParser.parse(lineSplitter.splitToList(TMCH_SMDRL))));
78+
}
79+
80+
@ParameterizedTest
81+
@MethodSource("provideTestCases")
82+
@SuppressWarnings("unused") // testCaseName
83+
void getClaimsList_production(String testCaseName, String tld) {
84+
var currEnv = RegistryEnvironment.get();
85+
try {
86+
PRODUCTION.setup();
87+
var claimsList = ClaimsListDao.get(tld);
88+
assertThat(claimsList.getClaimKey(TMCH_CLAIM_LABEL)).isPresent();
89+
assertThat(claimsList.getClaimKey(RST_CLAIM_LABEL)).isEmpty();
90+
} finally {
91+
currEnv.setup();
92+
}
93+
}
94+
95+
@ParameterizedTest
96+
@MethodSource("provideTestCases")
97+
@SuppressWarnings("unused") // testCaseName
98+
void getSmdrList_production(String testCaseName, String tld) {
99+
var currEnv = RegistryEnvironment.get();
100+
try {
101+
PRODUCTION.setup();
102+
var smdrl = SignedMarkRevocationList.get(tld);
103+
assertThat(smdrl.isSmdRevoked(TMCH_SMD_ID, now(UTC))).isTrue();
104+
assertThat(smdrl.isSmdRevoked(RST_SMD_ID, now(UTC))).isFalse();
105+
assertThat(smdrl.size()).isEqualTo(1);
106+
} finally {
107+
currEnv.setup();
108+
}
109+
}
110+
111+
@ParameterizedTest
112+
@MethodSource("provideTestCases")
113+
@SuppressWarnings("unused") // testCaseName
114+
void getClaimsList_sandbox(String testCaseName, String tld) {
115+
var currEnv = RegistryEnvironment.get();
116+
try {
117+
SANDBOX.setup();
118+
var claimsList = ClaimsListDao.get(tld);
119+
if (tld.equals("app")) {
120+
assertThat(claimsList.getClaimKey(TMCH_CLAIM_LABEL)).isPresent();
121+
assertThat(claimsList.getClaimKey(RST_CLAIM_LABEL)).isEmpty();
122+
} else {
123+
assertThat(claimsList.getClaimKey(TMCH_CLAIM_LABEL)).isEmpty();
124+
// Currently ote and prod have the same data.
125+
assertThat(claimsList.getClaimKey(RST_CLAIM_LABEL)).isPresent();
126+
}
127+
} finally {
128+
currEnv.setup();
129+
}
130+
}
131+
132+
@ParameterizedTest
133+
@MethodSource("provideTestCases")
134+
@SuppressWarnings("unused") // testCaseName
135+
void getSmdrList_sandbox(String testCaseName, String tld) {
136+
var currEnv = RegistryEnvironment.get();
137+
try {
138+
SANDBOX.setup();
139+
var smdrList = SignedMarkRevocationList.get(tld);
140+
if (tld.equals("app")) {
141+
assertThat(smdrList.size()).isEqualTo(1);
142+
assertThat(smdrList.isSmdRevoked(TMCH_SMD_ID, now(UTC))).isTrue();
143+
assertThat(smdrList.isSmdRevoked(RST_SMD_ID, now(UTC))).isFalse();
144+
} else {
145+
// Currently ote and prod have the same data.
146+
assertThat(smdrList.size()).isEqualTo(5);
147+
assertThat(smdrList.isSmdRevoked(TMCH_SMD_ID, now())).isFalse();
148+
assertThat(smdrList.isSmdRevoked(RST_SMD_ID, now())).isTrue();
149+
}
150+
} finally {
151+
currEnv.setup();
152+
}
153+
}
154+
155+
private static Stream<Arguments> provideTestCases() {
156+
return Stream.of(
157+
Arguments.of("NotRST", "app"),
158+
Arguments.of("OTE", "cc-rst-test-tld-1"),
159+
Arguments.of("PROD", "zz--idn-123"));
160+
}
161+
}

0 commit comments

Comments
 (0)