Skip to content

Commit

Permalink
#405 qulice is clean
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 9, 2023
1 parent fd6c8a2 commit db1b0b9
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 83 deletions.
10 changes: 8 additions & 2 deletions s3auth-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>2.2</version>
<scope>compile</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
<scope>compile</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
Expand Down
9 changes: 6 additions & 3 deletions s3auth-rest/src/main/java/com/s3auth/Launch.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
import com.s3auth.hosts.DynamoHosts;
import com.s3auth.hosts.SyslogHosts;
import com.s3auth.rest.TkApp;
import java.io.IOException;
import org.takes.http.Exit;
import org.takes.http.FtCLI;
import org.takes.http.FtCli;

/**
* Launch (used only for heroku).
Expand All @@ -51,9 +52,11 @@ private Launch() {
/**
* Entry point.
* @param args Command line args
* @throws IOException If fails
*/
public static void main(final String[] args) {
new FtCLI(
@SuppressWarnings("PMD.ProhibitPublicStaticMethods")
public static void main(final String[] args) throws IOException {
new FtCli(
new TkApp(new SyslogHosts(new DynamoHosts())),
args
).start(Exit.NEVER);
Expand Down
2 changes: 2 additions & 0 deletions s3auth-rest/src/main/java/com/s3auth/rest/RqUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ public User user() throws IOException {
public URN identity() {
return URN.create(identity.urn());
}

@Override
public String name() {
return identity.properties().get("name");
}

@Override
public URI photo() {
return URI.create(
Expand Down
8 changes: 4 additions & 4 deletions s3auth-rest/src/main/java/com/s3auth/rest/RsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.takes.rs.RsWithHeader;
import org.takes.rs.RsWithType;
import org.takes.rs.RsWrap;
import org.takes.rs.RsXSLT;
import org.takes.rs.RsXslt;
import org.takes.rs.xe.RsXembly;
import org.takes.rs.xe.XeAppend;
import org.takes.rs.xe.XeChain;
Expand All @@ -54,7 +54,7 @@
import org.takes.rs.xe.XeLinkSelf;
import org.takes.rs.xe.XeLocalhost;
import org.takes.rs.xe.XeMillis;
import org.takes.rs.xe.XeSLA;
import org.takes.rs.xe.XeSla;
import org.takes.rs.xe.XeSource;
import org.takes.rs.xe.XeStylesheet;

Expand Down Expand Up @@ -108,7 +108,7 @@ private static Response make(final String xsl,
new XeLinkHome(req),
new XeLinkSelf(req),
new XeDate(),
new XeSLA(),
new XeSla(),
new XeLocalhost(),
new XeIdentity(req),
new XeFlash(req),
Expand Down Expand Up @@ -136,7 +136,7 @@ private static Response make(final String xsl,
),
new FkTypes(
"*/*",
new RsXSLT(new RsWithType(raw, "text/html"))
new RsXslt(new RsWithType(raw, "text/html"))
)
),
"X-S3Auth-Version",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ final class SimpleDomain implements Domain {
* @param syslg The syslog host and port
* @checkstyle ParameterNumber (4 lines)
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
SimpleDomain(final String hst, final String access, final String scrt,
final String bckt, final String rgn, final String syslg) {
this.host = hst;
Expand Down
3 changes: 2 additions & 1 deletion s3auth-rest/src/main/java/com/s3auth/rest/TkAdd.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.takes.facets.flash.RsFlash;
import org.takes.facets.forward.RsForward;
import org.takes.rq.RqForm;
import org.takes.rq.form.RqFormBase;

/**
* Add a domain.
Expand All @@ -63,7 +64,7 @@ final class TkAdd implements Take {
@Override
public Response act(final Request request) throws IOException {
final User user = new RqUser(request).user();
final RqForm form = new RqForm(request);
final RqForm form = new RqFormBase(request);
final String host = form.param("host").iterator().next();
final boolean added = this.hosts.domains(user).add(
new SimpleDomain(
Expand Down
13 changes: 6 additions & 7 deletions s3auth-rest/src/main/java/com/s3auth/rest/TkApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Iterator;
import java.util.regex.Pattern;
import javax.validation.constraints.NotNull;
import org.apache.commons.lang3.exception.ExceptionUtils;
Expand All @@ -51,7 +49,7 @@
import org.takes.facets.auth.codecs.CcHex;
import org.takes.facets.auth.codecs.CcSafe;
import org.takes.facets.auth.codecs.CcSalted;
import org.takes.facets.auth.codecs.CcXOR;
import org.takes.facets.auth.codecs.CcXor;
import org.takes.facets.auth.social.PsFacebook;
import org.takes.facets.auth.social.PsGithub;
import org.takes.facets.auth.social.PsGoogle;
Expand All @@ -67,6 +65,7 @@
import org.takes.facets.fork.FkRegex;
import org.takes.facets.fork.TkFork;
import org.takes.facets.forward.TkForward;
import org.takes.misc.Opt;
import org.takes.rs.RsVelocity;
import org.takes.rs.RsWithStatus;
import org.takes.rs.RsWithType;
Expand Down Expand Up @@ -147,12 +146,12 @@ private static Take fallback(final Take takes) {
// @checkstyle AnonInnerLengthCheck (50 lines)
new Fallback() {
@Override
public Iterator<Response> route(final RqFallback req)
public Opt<Response> route(final RqFallback req)
throws IOException {
final String err = ExceptionUtils.getStackTrace(
req.throwable()
);
return Collections.<Response>singleton(
return new Opt.Single<>(
new RsWithStatus(
new RsWithType(
new RsVelocity(
Expand All @@ -166,7 +165,7 @@ public Iterator<Response> route(final RqFallback req)
),
HttpURLConnection.HTTP_INTERNAL_ERROR
)
).iterator();
);
}
}
)
Expand Down Expand Up @@ -216,7 +215,7 @@ private static Take auth(final Take takes) {
new PsCookie(
new CcSafe(
new CcHex(
new CcXOR(
new CcXor(
new CcSalted(new CcCompact()),
Manifests.read("S3Auth-SecurityKey")
)
Expand Down
9 changes: 2 additions & 7 deletions s3auth-rest/src/main/java/com/s3auth/rest/TkIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,9 @@ public Response act(final Request request) throws IOException {
new XeLink("add", "/add"),
new XeAppend(
"domains",
new XeTransform<Domain>(
new XeTransform<>(
this.hosts.domains(new RqUser(request).user()),
new XeTransform.Func<Domain>() {
@Override
public XeSource transform(final Domain domain) {
return TkIndex.source(domain);
}
}
TkIndex::source
)
)
);
Expand Down
Empty file.
55 changes: 0 additions & 55 deletions s3auth-rest/src/test/casperjs/RendersHomePage.js

This file was deleted.

2 changes: 1 addition & 1 deletion s3auth-rest/src/test/java/com/s3auth/rest/TkAppITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* Integration case for {@link TkApp}.
* @since 0.5
*/
public final class TkAppITCase {
final class TkAppITCase {

/**
* Home page of Tomcat.
Expand Down
4 changes: 1 addition & 3 deletions s3auth-rest/src/test/java/com/s3auth/rest/TkAppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
import com.jcabi.http.wire.VerboseWire;
import com.jcabi.matchers.XhtmlMatchers;
import com.s3auth.hosts.HostsMocker;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -82,7 +80,7 @@ void rendersHomePage() throws Exception {
*/
@Test
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public void rendersManyUrls() throws Exception {
void rendersManyUrls() throws Exception {
final Take take = new TkApp(
new HostsMocker().mock()
);
Expand Down

1 comment on commit db1b0b9

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on db1b0b9 Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 200-e1abb509 disappeared from s3auth-rest/src/test/casperjs/RendersHomePage.js), that's why I closed #354. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.