diff --git a/s3auth-rest/pom.xml b/s3auth-rest/pom.xml
index 841c364a..999fc8c6 100644
--- a/s3auth-rest/pom.xml
+++ b/s3auth-rest/pom.xml
@@ -87,13 +87,19 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
org.hamcrest
hamcrest-library
2.2
- compile
+ test
org.hamcrest
hamcrest-core
2.2
- compile
+ test
+
+
+ org.mockito
+ mockito-core
+ 5.7.0
+ test
com.jcabi
diff --git a/s3auth-rest/src/main/java/com/s3auth/Launch.java b/s3auth-rest/src/main/java/com/s3auth/Launch.java
index 2a61791b..2987688c 100644
--- a/s3auth-rest/src/main/java/com/s3auth/Launch.java
+++ b/s3auth-rest/src/main/java/com/s3auth/Launch.java
@@ -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).
@@ -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);
diff --git a/s3auth-rest/src/main/java/com/s3auth/rest/RqUser.java b/s3auth-rest/src/main/java/com/s3auth/rest/RqUser.java
index 915bc981..081e0fce 100644
--- a/s3auth-rest/src/main/java/com/s3auth/rest/RqUser.java
+++ b/s3auth-rest/src/main/java/com/s3auth/rest/RqUser.java
@@ -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(
diff --git a/s3auth-rest/src/main/java/com/s3auth/rest/RsPage.java b/s3auth-rest/src/main/java/com/s3auth/rest/RsPage.java
index cd6394e1..18897fdf 100644
--- a/s3auth-rest/src/main/java/com/s3auth/rest/RsPage.java
+++ b/s3auth-rest/src/main/java/com/s3auth/rest/RsPage.java
@@ -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;
@@ -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;
@@ -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),
@@ -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",
diff --git a/s3auth-rest/src/main/java/com/s3auth/rest/SimpleDomain.java b/s3auth-rest/src/main/java/com/s3auth/rest/SimpleDomain.java
index 7971e203..c47f5e23 100644
--- a/s3auth-rest/src/main/java/com/s3auth/rest/SimpleDomain.java
+++ b/s3auth-rest/src/main/java/com/s3auth/rest/SimpleDomain.java
@@ -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;
diff --git a/s3auth-rest/src/main/java/com/s3auth/rest/TkAdd.java b/s3auth-rest/src/main/java/com/s3auth/rest/TkAdd.java
index 6826b063..59c08ada 100644
--- a/s3auth-rest/src/main/java/com/s3auth/rest/TkAdd.java
+++ b/s3auth-rest/src/main/java/com/s3auth/rest/TkAdd.java
@@ -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.
@@ -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(
diff --git a/s3auth-rest/src/main/java/com/s3auth/rest/TkApp.java b/s3auth-rest/src/main/java/com/s3auth/rest/TkApp.java
index bd22fee8..3cc5fa4d 100644
--- a/s3auth-rest/src/main/java/com/s3auth/rest/TkApp.java
+++ b/s3auth-rest/src/main/java/com/s3auth/rest/TkApp.java
@@ -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;
@@ -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;
@@ -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;
@@ -147,12 +146,12 @@ private static Take fallback(final Take takes) {
// @checkstyle AnonInnerLengthCheck (50 lines)
new Fallback() {
@Override
- public Iterator route(final RqFallback req)
+ public Opt route(final RqFallback req)
throws IOException {
final String err = ExceptionUtils.getStackTrace(
req.throwable()
);
- return Collections.singleton(
+ return new Opt.Single<>(
new RsWithStatus(
new RsWithType(
new RsVelocity(
@@ -166,7 +165,7 @@ public Iterator route(final RqFallback req)
),
HttpURLConnection.HTTP_INTERNAL_ERROR
)
- ).iterator();
+ );
}
}
)
@@ -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")
)
diff --git a/s3auth-rest/src/main/java/com/s3auth/rest/TkIndex.java b/s3auth-rest/src/main/java/com/s3auth/rest/TkIndex.java
index 4248d871..1ea76364 100644
--- a/s3auth-rest/src/main/java/com/s3auth/rest/TkIndex.java
+++ b/s3auth-rest/src/main/java/com/s3auth/rest/TkIndex.java
@@ -72,14 +72,9 @@ public Response act(final Request request) throws IOException {
new XeLink("add", "/add"),
new XeAppend(
"domains",
- new XeTransform(
+ new XeTransform<>(
this.hosts.domains(new RqUser(request).user()),
- new XeTransform.Func() {
- @Override
- public XeSource transform(final Domain domain) {
- return TkIndex.source(domain);
- }
- }
+ TkIndex::source
)
)
);
diff --git a/s3auth-rest/src/test/aspect/.gitkeep b/s3auth-rest/src/test/aspect/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/s3auth-rest/src/test/casperjs/RendersHomePage.js b/s3auth-rest/src/test/casperjs/RendersHomePage.js
deleted file mode 100644
index 2898fd7d..00000000
--- a/s3auth-rest/src/test/casperjs/RendersHomePage.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2012-2023, Yegor Bugayenko
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met: 1) Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer. 2) Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution. 3) Neither the name of the s3auth.com nor
- * the names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This is a simple test of home page rendering
- * @todo #200 Migrate old tests from rexsl/scripts to casperjs
- */
-
-casper.test.begin("Hello, Test!", 1, function(test) {
- test.assert(true);
- test.done();
-});
-//casper.test.begin(
-// 'Home page can be rendered',
-// function (test) {
-// casper.start(
-// casper.cli.get('home'),
-// function () {
-// test.assertHttpStatus(200);
-// }
-// );
-// casper.run(
-// function () {
-// test.done();
-// }
-// );
-// }
-//);
\ No newline at end of file
diff --git a/s3auth-rest/src/test/java/com/s3auth/rest/TkAppITCase.java b/s3auth-rest/src/test/java/com/s3auth/rest/TkAppITCase.java
index d9681618..4dd9cd5f 100644
--- a/s3auth-rest/src/test/java/com/s3auth/rest/TkAppITCase.java
+++ b/s3auth-rest/src/test/java/com/s3auth/rest/TkAppITCase.java
@@ -44,7 +44,7 @@
* Integration case for {@link TkApp}.
* @since 0.5
*/
-public final class TkAppITCase {
+final class TkAppITCase {
/**
* Home page of Tomcat.
diff --git a/s3auth-rest/src/test/java/com/s3auth/rest/TkAppTest.java b/s3auth-rest/src/test/java/com/s3auth/rest/TkAppTest.java
index 31f2cc90..7be0f576 100644
--- a/s3auth-rest/src/test/java/com/s3auth/rest/TkAppTest.java
+++ b/s3auth-rest/src/test/java/com/s3auth/rest/TkAppTest.java
@@ -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;
@@ -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()
);