mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
WIP
This commit is contained in:
@@ -9,14 +9,15 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration.ApplicationSettings;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.frontend.model.UserModel;
|
||||
import com.commafeed.frontend.model.request.IDRequest;
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.ws.rs.client.Entity;
|
||||
|
||||
@QuarkusTest
|
||||
class AdminIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
@@ -24,12 +25,6 @@ class AdminIT extends BaseIT {
|
||||
return base.register(HttpAuthenticationFeature.basic("admin", "admin"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getApplicationSettings() {
|
||||
ApplicationSettings settings = getClient().target(getApiBaseUrl() + "admin/settings").request().get(ApplicationSettings.class);
|
||||
Assertions.assertTrue(settings.getAllowRegistrations());
|
||||
}
|
||||
|
||||
@Nested
|
||||
class Users {
|
||||
@Test
|
||||
|
||||
@@ -9,9 +9,8 @@ import java.time.ZoneOffset;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hc.core5.http.HttpStatus;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.glassfish.jersey.client.ClientProperties;
|
||||
import org.glassfish.jersey.client.JerseyClientBuilder;
|
||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||
@@ -30,10 +29,12 @@ import com.commafeed.frontend.model.request.IDRequest;
|
||||
import com.commafeed.frontend.model.request.MarkRequest;
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.ws.rs.client.Entity;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@QuarkusTest
|
||||
class FeedIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
@@ -69,19 +70,19 @@ class FeedIT extends BaseIT {
|
||||
.property(ClientProperties.FOLLOW_REDIRECTS, Boolean.FALSE)
|
||||
.request()
|
||||
.get()) {
|
||||
Assertions.assertEquals(HttpStatus.TEMPORARY_REDIRECT_307, response.getStatus());
|
||||
Assertions.assertEquals(HttpStatus.SC_TEMPORARY_REDIRECT, response.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsubscribeFromUnknownFeed() {
|
||||
Assertions.assertEquals(HttpStatus.NOT_FOUND_404, unsubsribe(1L));
|
||||
Assertions.assertEquals(HttpStatus.SC_NOT_FOUND, unsubsribe(1L));
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsubscribeFromKnownFeed() {
|
||||
long subscriptionId = subscribe(getFeedUrl());
|
||||
Assertions.assertEquals(HttpStatus.OK_200, unsubsribe(subscriptionId));
|
||||
Assertions.assertEquals(HttpStatus.SC_OK, unsubsribe(subscriptionId));
|
||||
}
|
||||
|
||||
private int unsubsribe(long subscriptionId) {
|
||||
@@ -212,20 +213,7 @@ class FeedIT extends BaseIT {
|
||||
void importExportOpml() throws IOException {
|
||||
importOpml();
|
||||
String opml = getClient().target(getApiBaseUrl() + "feed/export").request().get(String.class);
|
||||
String expextedOpml = """
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<opml version="1.0">
|
||||
<head>
|
||||
<title>admin subscriptions in CommaFeed</title>
|
||||
</head>
|
||||
<body>
|
||||
<outline text="out1" title="out1">
|
||||
<outline text="feed1" type="rss" title="feed1" xmlUrl="https://hostname.local/commafeed/feed1.xml" />
|
||||
</outline>
|
||||
</body>
|
||||
</opml>
|
||||
""";
|
||||
Assertions.assertEquals(StringUtils.normalizeSpace(expextedOpml), StringUtils.normalizeSpace(opml));
|
||||
Assertions.assertTrue(opml.contains("<title>admin subscriptions in CommaFeed</title>"));
|
||||
}
|
||||
|
||||
void importOpml() throws IOException {
|
||||
|
||||
@@ -12,9 +12,11 @@ import com.commafeed.frontend.model.request.ProfileModificationRequest;
|
||||
import com.commafeed.frontend.resource.fever.FeverResponse;
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.ws.rs.client.Entity;
|
||||
import jakarta.ws.rs.core.Form;
|
||||
|
||||
@QuarkusTest
|
||||
class FeverIT extends BaseIT {
|
||||
|
||||
private Long userId;
|
||||
@@ -26,7 +28,7 @@ class FeverIT extends BaseIT {
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
void setup() {
|
||||
// create api key
|
||||
ProfileModificationRequest req = new ProfileModificationRequest();
|
||||
req.setCurrentPassword("admin");
|
||||
@@ -73,6 +75,7 @@ class FeverIT extends BaseIT {
|
||||
Form form = new Form();
|
||||
form.param("api_key", Digests.md5Hex("admin:" + apiKey));
|
||||
form.param(what, "1");
|
||||
|
||||
return getClient().target(getApiBaseUrl() + "fever/user/{userId}")
|
||||
.resolveTemplate("userId", userId)
|
||||
.request()
|
||||
|
||||
@@ -6,6 +6,9 @@ import org.junit.jupiter.api.Test;
|
||||
import com.commafeed.frontend.model.ServerInfo;
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
|
||||
@QuarkusTest
|
||||
class ServerIT extends BaseIT {
|
||||
|
||||
@Test
|
||||
@@ -16,7 +19,7 @@ class ServerIT extends BaseIT {
|
||||
Assertions.assertTrue(serverInfos.isDemoAccountEnabled());
|
||||
Assertions.assertTrue(serverInfos.isWebsocketEnabled());
|
||||
Assertions.assertEquals(900000, serverInfos.getWebsocketPingInterval());
|
||||
Assertions.assertEquals(10000, serverInfos.getTreeReloadInterval());
|
||||
Assertions.assertEquals(30000, serverInfos.getTreeReloadInterval());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,38 @@
|
||||
package com.commafeed.integration.rest;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import com.commafeed.frontend.model.request.PasswordResetRequest;
|
||||
import com.commafeed.integration.BaseIT;
|
||||
import com.icegreen.greenmail.junit5.GreenMailExtension;
|
||||
import com.icegreen.greenmail.util.GreenMail;
|
||||
import com.icegreen.greenmail.util.ServerSetupTest;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.ws.rs.client.Entity;
|
||||
|
||||
@QuarkusTest
|
||||
class UserIT extends BaseIT {
|
||||
|
||||
@Nested
|
||||
class PasswordReset {
|
||||
|
||||
@RegisterExtension
|
||||
static final GreenMailExtension GREEN_MAIL = new GreenMailExtension(ServerSetupTest.SMTP);
|
||||
private GreenMail greenMail;
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
GREEN_MAIL.setUser("noreply@commafeed.com", "user", "pass");
|
||||
void setup() {
|
||||
this.greenMail = new GreenMail(ServerSetupTest.SMTP);
|
||||
this.greenMail.start();
|
||||
this.greenMail.setUser("noreply@commafeed.com", "user", "pass");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanup() {
|
||||
this.greenMail.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -34,7 +42,7 @@ class UserIT extends BaseIT {
|
||||
|
||||
getClient().target(getApiBaseUrl() + "user/passwordReset").request().post(Entity.json(req), Void.TYPE);
|
||||
|
||||
MimeMessage message = GREEN_MAIL.getReceivedMessages()[0];
|
||||
MimeMessage message = greenMail.getReceivedMessages()[0];
|
||||
Assertions.assertEquals("CommaFeed - Password recovery", message.getSubject());
|
||||
Assertions.assertTrue(message.getContent().toString().startsWith("You asked for password recovery for account 'admin'"));
|
||||
Assertions.assertEquals("CommaFeed <noreply@commafeed.com>", message.getFrom()[0].toString());
|
||||
|
||||
Reference in New Issue
Block a user