mirror of
https://github.com/google/nomulus.git
synced 2025-05-05 14:37:52 +02:00
This CL is to address the public static field in RepeatableRunner for caller to get the current attempt number. We tried to have a JUnit TestRule to achieve the purpose but it ended up with having a RuleChain in each class where we already have multiple rules and need to add the retry rule. This is because we have to make sure the retry rule is the last one to wrap the test statement so that the actual retry can include the actions defined in other rules. Having a rule chain is not scalable and confuses engineer so we gave it up. Instead, we decided to expand the current RepeatableRunner to use reflection to inject the attempt number to the test class. Doing it this way can reduce the burden from the caller and it also gets rid of the global state from the previous public static field. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=240789045
80 lines
3 KiB
Java
80 lines
3 KiB
Java
// Copyright 2018 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.webdriver;
|
|
|
|
import static google.registry.server.Fixture.BASIC;
|
|
import static google.registry.server.Route.route;
|
|
|
|
import com.googlecode.objectify.ObjectifyFilter;
|
|
import google.registry.model.ofy.OfyFilter;
|
|
import google.registry.module.frontend.FrontendServlet;
|
|
import google.registry.server.RegistryTestServer;
|
|
import google.registry.webdriver.RepeatableRunner.AttemptNumber;
|
|
import org.junit.Rule;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.openqa.selenium.By;
|
|
|
|
/** Registrar Console Screenshot Differ tests. */
|
|
@RunWith(RepeatableRunner.class)
|
|
public class OteSetupConsoleScreenshotTest {
|
|
|
|
@Rule
|
|
public final TestServerRule server =
|
|
new TestServerRule.Builder()
|
|
.setRunfiles(RegistryTestServer.RUNFILES)
|
|
.setRoutes(route("/registrar-ote-setup", FrontendServlet.class))
|
|
.setFilters(ObjectifyFilter.class, OfyFilter.class)
|
|
.setFixtures(BASIC)
|
|
.setEmail("Marla.Singer@google.com")
|
|
.build();
|
|
|
|
private final AttemptNumber attemptNumber = new AttemptNumber();
|
|
@Rule public final WebDriverRule driver = new WebDriverRule(attemptNumber);
|
|
|
|
@Test
|
|
public void get_owner_fails() throws Throwable {
|
|
driver.get(server.getUrl("/registrar-ote-setup"));
|
|
driver.waitForElement(By.tagName("h1"));
|
|
driver.diffPage("unauthorized");
|
|
}
|
|
|
|
@Test
|
|
public void get_admin_succeeds() throws Throwable {
|
|
server.setIsAdmin(true);
|
|
driver.get(server.getUrl("/registrar-ote-setup"));
|
|
driver.waitForElement(By.tagName("h1"));
|
|
driver.diffPage("formEmpty");
|
|
driver.findElement(By.id("clientId")).sendKeys("acmereg");
|
|
driver.findElement(By.id("email")).sendKeys("acmereg@registry.example");
|
|
driver.findElement(By.id("password")).sendKeys("StRoNgPaSsWoRd");
|
|
driver.diffPage("formFilled");
|
|
driver.findElement(By.id("submit-button")).click();
|
|
driver.waitForElement(By.tagName("h1"));
|
|
driver.diffPage("oteResult");
|
|
}
|
|
|
|
@Test
|
|
public void get_admin_fails_badEmail() throws Throwable {
|
|
server.setIsAdmin(true);
|
|
driver.get(server.getUrl("/registrar-ote-setup"));
|
|
driver.waitForElement(By.tagName("h1"));
|
|
driver.findElement(By.id("clientId")).sendKeys("acmereg");
|
|
driver.findElement(By.id("email")).sendKeys("bad email");
|
|
driver.findElement(By.id("submit-button")).click();
|
|
driver.waitForElement(By.tagName("h1"));
|
|
driver.diffPage("oteResultFailed");
|
|
}
|
|
}
|