Remove files that are not longer used for create/update premium list (#1288)

* Remove files that are not longer used for create/update premium list

* Remove comments/notes related to create/update premium list action files
This commit is contained in:
Rachel Guan
2021-08-18 14:04:57 -04:00
committed by GitHub
parent 5339b3cb6c
commit 52c18f9967
12 changed files with 1 additions and 482 deletions
@@ -1,109 +0,0 @@
// Copyright 2017 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.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.loadPremiumEntries;
import static javax.servlet.http.HttpServletResponse.SC_OK;
import static org.joda.money.CurrencyUnit.USD;
import google.registry.model.tld.label.PremiumList;
import google.registry.model.tld.label.PremiumListDao;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.FakeJsonResponse;
import org.joda.money.Money;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Unit tests for {@link CreatePremiumListAction}.
*/
public class CreatePremiumListActionTest {
@RegisterExtension
public final AppEngineExtension appEngine =
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
private CreatePremiumListAction action;
private FakeJsonResponse response;
@BeforeEach
void beforeEach() {
createTlds("foo", "xn--q9jyb4c", "how");
PremiumListDao.delete(PremiumListDao.getLatestRevision("foo").get());
action = new CreatePremiumListAction();
response = new FakeJsonResponse();
action.response = response;
}
@Test
void test_invalidRequest_missingInput_returnsErrorStatus() {
action.name = "foo";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
}
@Test
void test_invalidRequest_listAlreadyExists_returnsErrorStatus() {
action.name = "how";
action.inputData = "richer,JPY 5000";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
Object obj = response.getResponseMap().get("error");
assertThat(obj).isInstanceOf(String.class);
String error = obj.toString();
assertThat(error).contains("A premium list of this name already exists");
}
@Test
void test_nonExistentTld_fails() {
action.name = "zanzibar";
action.inputData = "zanzibar,USD 100";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
assertThat(response.getResponseMap().get("error").toString())
.isEqualTo(
"Premium names must match the name of the TLD they are intended to be used on"
+ " (unless --override is specified), yet TLD zanzibar does not exist");
}
@Test
void test_nonExistentTld_successWithOverride() {
action.name = "zanzibar";
action.inputData = "zanzibar,USD 100";
action.override = true;
action.currency = USD;
action.run();
assertThat(response.getStatus()).isEqualTo(SC_OK);
assertThat(loadPremiumEntries(PremiumListDao.getLatestRevision("zanzibar").get())).hasSize(1);
}
@Test
void test_success() {
action.name = "foo";
action.inputData = "rich,USD 25\nricher,USD 1000\n";
action.currency = USD;
action.run();
assertThat(response.getStatus()).isEqualTo(SC_OK);
PremiumList premiumList = PremiumListDao.getLatestRevision("foo").get();
assertThat(loadPremiumEntries(premiumList)).hasSize(2);
assertThat(PremiumListDao.getPremiumPrice(premiumList.getName(), "rich"))
.hasValue(Money.parse("USD 25"));
assertThat(PremiumListDao.getPremiumPrice(premiumList.getName(), "diamond")).isEmpty();
}
}
@@ -1,110 +0,0 @@
// Copyright 2017 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.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.loadPremiumEntries;
import static google.registry.util.ResourceUtils.readResourceUtf8;
import static javax.servlet.http.HttpServletResponse.SC_OK;
import static org.joda.money.CurrencyUnit.USD;
import com.google.common.base.Splitter;
import com.google.common.truth.Truth8;
import google.registry.model.tld.label.PremiumList;
import google.registry.model.tld.label.PremiumListDao;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeJsonResponse;
import java.math.BigDecimal;
import java.util.List;
import org.joda.money.Money;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link UpdatePremiumListAction}. */
class UpdatePremiumListActionTest {
@RegisterExtension
final AppEngineExtension appEngine =
AppEngineExtension.builder().withDatastoreAndCloudSql().build();
private UpdatePremiumListAction action;
private FakeJsonResponse response;
@BeforeEach
void beforeEach() {
createTlds("foo", "xn--q9jyb4c", "how");
action = new UpdatePremiumListAction();
response = new FakeJsonResponse();
action.response = response;
}
@Test
void test_invalidRequest_missingInput_returnsErrorStatus() {
action.name = "foo";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
}
@Test
void test_invalidRequest_listDoesNotExist_returnsErrorStatus() {
action.name = "bamboozle";
action.inputData = "richer,JPY 5000";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
Object obj = response.getResponseMap().get("error");
assertThat(obj).isInstanceOf(String.class);
String error = obj.toString();
assertThat(error).contains("Could not update premium list");
}
@Test
void test_success() {
List<String> inputLines =
Splitter.on('\n')
.omitEmptyStrings()
.splitToList(
readResourceUtf8(DatabaseHelper.class, "default_premium_list_testdata.csv"));
PremiumListDao.save("foo", USD, inputLines);
action.name = "foo";
action.inputData = "rich,USD 75\nricher,USD 5000\npoor, USD 0.99";
action.run();
assertThat(response.getStatus()).isEqualTo(SC_OK);
assertThat(loadPremiumEntries(PremiumListDao.getLatestRevision("foo").get())).hasSize(3);
Truth8.assertThat(PremiumListDao.getPremiumPrice("foo", "rich"))
.hasValue(Money.parse("USD 75"));
Truth8.assertThat(PremiumListDao.getPremiumPrice("foo", "richer"))
.hasValue(Money.parse("USD 5000"));
Truth8.assertThat(PremiumListDao.getPremiumPrice("foo", "poor"))
.hasValue(Money.parse("USD 0.99"));
Truth8.assertThat(PremiumListDao.getPremiumPrice("foo", "diamond")).isEmpty();
jpaTm()
.transact(
() -> {
PremiumList persistedList = PremiumListDao.getLatestRevision("foo").get();
assertThat(persistedList.getLabelsToPrices())
.containsEntry("rich", new BigDecimal("75.00"));
assertThat(persistedList.getLabelsToPrices())
.containsEntry("richer", new BigDecimal("5000.00"));
assertThat(persistedList.getLabelsToPrices())
.containsEntry("poor", BigDecimal.valueOf(0.99));
assertThat(persistedList.getLabelsToPrices()).doesNotContainKey("diamond");
});
}
}
@@ -1,13 +1,11 @@
PATH CLASS METHODS OK AUTH_METHODS MIN USER_POLICY
/_dr/admin/createGroups CreateGroupsAction POST n INTERNAL,API APP ADMIN
/_dr/admin/createPremiumList CreatePremiumListAction POST n INTERNAL,API APP ADMIN
/_dr/admin/list/domains ListDomainsAction GET,POST n INTERNAL,API APP ADMIN
/_dr/admin/list/hosts ListHostsAction GET,POST n INTERNAL,API APP ADMIN
/_dr/admin/list/premiumLists ListPremiumListsAction GET,POST n INTERNAL,API APP ADMIN
/_dr/admin/list/registrars ListRegistrarsAction GET,POST n INTERNAL,API APP ADMIN
/_dr/admin/list/reservedLists ListReservedListsAction GET,POST n INTERNAL,API APP ADMIN
/_dr/admin/list/tlds ListTldsAction GET,POST n INTERNAL,API APP ADMIN
/_dr/admin/updatePremiumList UpdatePremiumListAction POST n INTERNAL,API APP ADMIN
/_dr/admin/verifyOte VerifyOteAction POST n INTERNAL,API APP ADMIN
/_dr/epptool EppToolAction POST n INTERNAL,API APP ADMIN
/_dr/loadtest LoadTestAction POST y INTERNAL,API APP ADMIN