Add an action to check the status of OT&E verification

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=228333195
This commit is contained in:
Shicong Huang 2019-01-08 08:18:30 -08:00
parent c3de49130a
commit a79e254e49
9 changed files with 346 additions and 10 deletions

View file

@ -361,7 +361,7 @@ public final class OteAccountBuilder {
}
/** Returns the ClientIds of the OT&E, with the TLDs each has access to. */
static ImmutableMap<String, String> createClientIdToTldMap(String baseClientId) {
public static ImmutableMap<String, String> createClientIdToTldMap(String baseClientId) {
checkArgument(
REGISTRAR_PATTERN.matcher(baseClientId).matches(),
"Invalid registrar name: %s",
@ -374,4 +374,17 @@ public final class OteAccountBuilder {
.put(baseClientId + "-5", baseClientId + "-eap")
.build();
}
/** Returns the base client ID that correspond to a given OT&amp;E client ID. */
public static String getBaseClientId(String oteClientId) {
int index = oteClientId.lastIndexOf('-');
checkArgument(index > 0, "Invalid OT&E client ID: %s", oteClientId);
String baseClientId = oteClientId.substring(0, index);
checkArgument(
createClientIdToTldMap(baseClientId).containsKey(oteClientId),
"ID %s is not one of the OT&E client IDs for base %s",
oteClientId,
baseClientId);
return baseClientId;
}
}