Skip to content

Commit

Permalink
#10 forward fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Sep 25, 2016
1 parent 3b359c9 commit 64048d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/io/jare/tk/TkAdd.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,24 @@ public Response act(final Request req) throws IOException {
try {
new SafeUser(this.base.user(new RqUser(req).name())).add(name);
} catch (final SafeUser.InvalidNameException ex) {
throw new RsForward(new RsFlash(ex));
throw TkAdd.forward(new RsFlash(ex));
}
return new RsForward(
return TkAdd.forward(
new RsFlash(
String.format(
"domain \"%s\" added", name
)
),
"/domains"
)
);
}

/**
* Make forward.
* @param rsp Response
* @return Forward
*/
private static RsForward forward(final Response rsp) {
return new RsForward(rsp, "/domains");
}

}
2 changes: 2 additions & 0 deletions src/test/java/io/jare/smarts/SafeUserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void acceptsValidDomains() throws Exception {
* @throws Exception If some problem inside
*/
@Test
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
public void rejectsInvalidDomains() throws Exception {
final User user = new SafeUser(new FkUser());
final String[] domains = {
Expand All @@ -70,6 +71,7 @@ public void rejectsInvalidDomains() throws Exception {
"www-1 .google.com",
"google.УА",
"www-8=9.google.ua",
"127.0.0.1",
};
for (final String domain : domains) {
try {
Expand Down

0 comments on commit 64048d6

Please sign in to comment.