-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suspend / unsuspend to the console
- Loading branch information
Showing
8 changed files
with
237 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.../java/google/registry/ui/server/console/domains/ConsoleBulkDomainUnsuspendActionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2025 The Nomulus Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package google.registry.ui.server.console.domains; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.google.gson.JsonElement; | ||
import google.registry.model.console.ConsolePermission; | ||
|
||
/** An action that will unsuspend the given domain, removing all 5 server*Prohibited statuses. */ | ||
public class ConsoleBulkDomainUnsuspendActionType implements ConsoleDomainActionType { | ||
|
||
private static final String DOMAIN_SUSPEND_XML = | ||
""" | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<epp | ||
xmlns="urn:ietf:params:xml:ns:epp-1.0"> | ||
<command> | ||
<update> | ||
<domain:update | ||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"> | ||
<domain:name>%DOMAIN_NAME%</domain:name> | ||
<domain:add></domain:add> | ||
<domain:rem> | ||
<domain:status s="serverDeleteProhibited" lang="en"></domain:status> | ||
<domain:status s="serverHold" lang="en"></domain:status> | ||
<domain:status s="serverRenewProhibited" lang="en"></domain:status> | ||
<domain:status s="serverTransferProhibited" lang="en"></domain:status> | ||
<domain:status s="serverUpdateProhibited" lang="en"></domain:status> | ||
</domain:rem> | ||
</domain:update> | ||
</update> | ||
<extension> | ||
<metadata:metadata | ||
xmlns:metadata="urn:google:params:xml:ns:metadata-1.0"> | ||
<metadata:reason>Console unsuspension: %REASON%</metadata:reason> | ||
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar> | ||
</metadata:metadata> | ||
</extension> | ||
<clTRID>RegistryConsole</clTRID> | ||
</command> | ||
</epp>"""; | ||
|
||
private final String reason; | ||
|
||
public ConsoleBulkDomainUnsuspendActionType(JsonElement jsonElement) { | ||
this.reason = jsonElement.getAsJsonObject().get("reason").getAsString(); | ||
} | ||
|
||
@Override | ||
public String getXmlContentsToRun(String domainName) { | ||
return ConsoleDomainActionType.fillSubstitutions( | ||
DOMAIN_SUSPEND_XML, ImmutableMap.of("DOMAIN_NAME", domainName, "REASON", reason)); | ||
} | ||
|
||
@Override | ||
public ConsolePermission getNecessaryPermission() { | ||
return ConsolePermission.SUSPEND_DOMAIN; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.ImmutableSet; | ||
import com.google.common.collect.ImmutableSortedMap; | ||
import com.google.gson.Gson; | ||
import com.google.gson.JsonElement; | ||
|
@@ -61,6 +62,14 @@ public class ConsoleBulkDomainActionTest { | |
|
||
private static final Gson GSON = GsonUtils.provideGson(); | ||
|
||
private static ImmutableSet<StatusValue> serverSuspensionStatuses = | ||
ImmutableSet.of( | ||
StatusValue.SERVER_RENEW_PROHIBITED, | ||
StatusValue.SERVER_TRANSFER_PROHIBITED, | ||
StatusValue.SERVER_UPDATE_PROHIBITED, | ||
StatusValue.SERVER_DELETE_PROHIBITED, | ||
StatusValue.SERVER_HOLD); | ||
|
||
private final FakeClock clock = new FakeClock(DateTime.parse("2024-05-13T00:00:00.000Z")); | ||
|
||
@RegisterExtension | ||
|
@@ -135,12 +144,34 @@ void testSuccess_suspend() throws Exception { | |
""" | ||
{"example.tld":{"message":"Command completed successfully","responseCode":1000}}"""); | ||
assertThat(loadByEntity(domain).getStatusValues()) | ||
.containsAtLeast( | ||
StatusValue.SERVER_RENEW_PROHIBITED, | ||
StatusValue.SERVER_TRANSFER_PROHIBITED, | ||
StatusValue.SERVER_UPDATE_PROHIBITED, | ||
StatusValue.SERVER_DELETE_PROHIBITED, | ||
StatusValue.SERVER_HOLD); | ||
.containsAtLeastElementsIn(serverSuspensionStatuses); | ||
} | ||
|
||
@Test | ||
void testSuccess_unsuspend() throws Exception { | ||
User adminUser = | ||
persistResource( | ||
new User.Builder() | ||
.setEmailAddress("[email protected]") | ||
.setUserRoles( | ||
new UserRoles.Builder().setGlobalRole(GlobalRole.FTE).setIsAdmin(true).build()) | ||
.build()); | ||
persistResource(domain.asBuilder().addStatusValues(serverSuspensionStatuses).build()); | ||
ConsoleBulkDomainAction action = | ||
createAction( | ||
"UNSUSPEND", | ||
GSON.toJsonTree( | ||
ImmutableMap.of("domainList", ImmutableList.of("example.tld"), "reason", "test")), | ||
adminUser); | ||
assertThat(loadByEntity(domain).getStatusValues()) | ||
.containsAtLeastElementsIn(serverSuspensionStatuses); | ||
action.run(); | ||
assertThat(fakeResponse.getStatus()).isEqualTo(SC_OK); | ||
assertThat(fakeResponse.getPayload()) | ||
.isEqualTo( | ||
""" | ||
{"example.tld":{"message":"Command completed successfully","responseCode":1000}}"""); | ||
assertThat(loadByEntity(domain).getStatusValues()).containsNoneIn(serverSuspensionStatuses); | ||
} | ||
|
||
@Test | ||
|
Binary file modified
BIN
+1 Byte
(100%)
...ldens/chrome-linux/ConsoleScreenshotTest_dums_mainPage_actionsButtonClicked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.