mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
add more tests
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.commafeed.integration.servlet;
|
||||
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.commafeed.frontend.model.Settings;
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
class CustomCodeIT extends BaseIT {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
// get settings
|
||||
Settings settings = null;
|
||||
try (Response response = getClient().target(getApiBaseUrl() + "user/settings").request().get()) {
|
||||
settings = response.readEntity(Settings.class);
|
||||
}
|
||||
|
||||
// update settings
|
||||
settings.setCustomJs("custom-js");
|
||||
settings.setCustomCss("custom-css");
|
||||
try (Response response = getClient().target(getApiBaseUrl() + "user/settings").request().post(Entity.json(settings))) {
|
||||
Assertions.assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
}
|
||||
|
||||
// check custom code servlets
|
||||
String cookie = login();
|
||||
try (Response response = getClient().target(getBaseUrl() + "custom_js.js")
|
||||
.request()
|
||||
.header(HttpHeaders.COOKIE, "JSESSIONID=" + cookie)
|
||||
.get()) {
|
||||
Assertions.assertEquals("custom-js", response.readEntity(String.class));
|
||||
}
|
||||
try (Response response = getClient().target(getBaseUrl() + "custom_css.css")
|
||||
.request()
|
||||
.header(HttpHeaders.COOKIE, "JSESSIONID=" + cookie)
|
||||
.get()) {
|
||||
Assertions.assertEquals("custom-css", response.readEntity(String.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.commafeed.integration.servlet;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.glassfish.jersey.client.ClientProperties;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
class LogoutIT extends BaseIT {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
String cookie = login();
|
||||
try (Response response = getClient().target(getBaseUrl() + "logout")
|
||||
.request()
|
||||
.header(HttpHeaders.COOKIE, "JSESSIONID=" + cookie)
|
||||
.property(ClientProperties.FOLLOW_REDIRECTS, Boolean.FALSE)
|
||||
.get()) {
|
||||
Assertions.assertEquals(HttpStatus.FOUND_302, response.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.commafeed.integration.servlet;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.glassfish.jersey.client.ClientProperties;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
class NextUnreadIT extends BaseIT {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
|
||||
|
||||
String cookie = login();
|
||||
Response response = getClient().target(getBaseUrl() + "next")
|
||||
.property(ClientProperties.FOLLOW_REDIRECTS, Boolean.FALSE)
|
||||
.request()
|
||||
.header(HttpHeaders.COOKIE, "JSESSIONID=" + cookie)
|
||||
.get();
|
||||
Assertions.assertEquals(HttpStatus.FOUND_302, response.getStatus());
|
||||
Assertions.assertEquals("https://hostname.local/commafeed/2", response.getHeaderString(HttpHeaders.LOCATION));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.commafeed.integration.servlet;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
class RobotsTxtIT extends BaseIT {
|
||||
@Test
|
||||
void test() {
|
||||
try (Response response = getClient().target(getBaseUrl() + "robots.txt").request().get()) {
|
||||
Assertions.assertEquals("User-agent: *\nDisallow: /", response.readEntity(String.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user