mirror of
https://github.com/google/nomulus.git
synced 2025-07-08 12:13:19 +02:00
Refactor assertCommandAndResponse to be "fluent"
This is in preparation for automatic EPP consolidation. The assertion will now look like: assertThatCommand("file.xml"[, substitution]) .atTime(time) .hasResponse("file2.xml"[, substitution]); Also, added convenience functions for often reused commands (login and logout) ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190617505
This commit is contained in:
parent
c1ca88ac9e
commit
422ec9b97a
15 changed files with 892 additions and 1054 deletions
|
@ -37,7 +37,7 @@ public class EppLoginUserTest extends EppTestCase {
|
|||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
.withDatastore()
|
||||
.withUserService(UserInfo.create("person@example.com", "12345"))
|
||||
.withUserService(UserInfo.create("user@example.com", "12345"))
|
||||
.build();
|
||||
|
||||
@Before
|
||||
|
@ -55,40 +55,38 @@ public class EppLoginUserTest extends EppTestCase {
|
|||
|
||||
@Test
|
||||
public void testLoginLogout() throws Exception {
|
||||
assertCommandAndResponse("login_valid.xml", "login_response.xml");
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonAuthedLogin_fails() throws Exception {
|
||||
assertCommandAndResponse(
|
||||
"login2_valid.xml",
|
||||
ImmutableMap.of(),
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
"MSG", "User id is not allowed to login as requested registrar: person@example.com",
|
||||
"CODE", "2200"));
|
||||
assertThatLogin("TheRegistrar", "password2")
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
"CODE", "2200",
|
||||
"MSG", "User id is not allowed to login as requested registrar: user@example.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiLogin() throws Exception {
|
||||
assertCommandAndResponse("login_valid.xml", "login_response.xml");
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
assertCommandAndResponse("login_valid.xml", "login_response.xml");
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
assertCommandAndResponse(
|
||||
"login2_valid.xml",
|
||||
ImmutableMap.of(),
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
"MSG", "User id is not allowed to login as requested registrar: person@example.com",
|
||||
"CODE", "2200"));
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatLogoutSucceeds();
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatLogoutSucceeds();
|
||||
assertThatLogin("TheRegistrar", "password2")
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
"CODE", "2200",
|
||||
"MSG", "User id is not allowed to login as requested registrar: user@example.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoginLogout_wrongPasswordStillWorks() throws Exception {
|
||||
// For user-based logins the password in the epp xml is ignored.
|
||||
assertCommandAndResponse("login_invalid_wrong_password.xml", "login_response.xml");
|
||||
assertCommandAndResponse("logout.xml", "logout_response.xml");
|
||||
assertThatLoginSucceeds("NewRegistrar", "incorrect");
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue