forked from Archives/Athou_commafeed
change BaseIT test class so that authentication with the "admin" user is not the default
This commit is contained in:
@@ -10,7 +10,6 @@ import org.apache.commons.io.IOUtils;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.glassfish.jersey.client.JerseyClientBuilder;
|
||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -40,7 +39,12 @@ public abstract class BaseIT {
|
||||
|
||||
private static final HttpRequest FEED_REQUEST = HttpRequest.request().withMethod("GET").withPath("/");
|
||||
|
||||
private final CommaFeedDropwizardAppExtension extension = buildExtension();
|
||||
private final CommaFeedDropwizardAppExtension extension = new CommaFeedDropwizardAppExtension() {
|
||||
@Override
|
||||
protected JerseyClientBuilder clientBuilder() {
|
||||
return configureClientBuilder(super.clientBuilder().register(MultiPartFeature.class));
|
||||
}
|
||||
};
|
||||
|
||||
private Client client;
|
||||
|
||||
@@ -54,13 +58,8 @@ public abstract class BaseIT {
|
||||
|
||||
private MockServerClient mockServerClient;
|
||||
|
||||
protected CommaFeedDropwizardAppExtension buildExtension() {
|
||||
return new CommaFeedDropwizardAppExtension() {
|
||||
@Override
|
||||
protected JerseyClientBuilder clientBuilder() {
|
||||
return super.clientBuilder().register(HttpAuthenticationFeature.basic("admin", "admin")).register(MultiPartFeature.class);
|
||||
}
|
||||
};
|
||||
protected JerseyClientBuilder configureClientBuilder(JerseyClientBuilder base) {
|
||||
return base;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.commafeed.CommaFeedDropwizardAppExtension;
|
||||
import com.commafeed.frontend.model.Entries;
|
||||
import com.commafeed.frontend.model.UserModel;
|
||||
import com.commafeed.frontend.model.request.ProfileModificationRequest;
|
||||
@@ -18,12 +17,6 @@ import jakarta.ws.rs.core.Response;
|
||||
|
||||
class SecurityIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
protected CommaFeedDropwizardAppExtension buildExtension() {
|
||||
// override so we don't add http basic auth
|
||||
return new CommaFeedDropwizardAppExtension();
|
||||
}
|
||||
|
||||
@Test
|
||||
void notLoggedIn() {
|
||||
try (Response response = getClient().target(getApiBaseUrl() + "user/profile").request().get()) {
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.awaitility.Awaitility;
|
||||
import org.glassfish.jersey.client.JerseyClientBuilder;
|
||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -28,6 +30,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
class WebSocketIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
protected JerseyClientBuilder configureClientBuilder(JerseyClientBuilder base) {
|
||||
return base.register(HttpAuthenticationFeature.basic("admin", "admin"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sessionClosedIfNotLoggedIn() throws DeploymentException, IOException {
|
||||
AtomicBoolean connected = new AtomicBoolean();
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.commafeed.integration.rest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.glassfish.jersey.client.JerseyClientBuilder;
|
||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -17,6 +19,11 @@ import jakarta.ws.rs.client.Entity;
|
||||
|
||||
class AdminIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
protected JerseyClientBuilder configureClientBuilder(JerseyClientBuilder base) {
|
||||
return base.register(HttpAuthenticationFeature.basic("admin", "admin"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getApplicationSettings() {
|
||||
ApplicationSettings settings = getClient().target(getApiBaseUrl() + "admin/settings").request().get(ApplicationSettings.class);
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
import org.glassfish.jersey.media.multipart.MultiPart;
|
||||
import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -34,6 +36,11 @@ import jakarta.ws.rs.core.Response;
|
||||
|
||||
class FeedIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
protected JerseyClientBuilder configureClientBuilder(JerseyClientBuilder base) {
|
||||
return base.register(HttpAuthenticationFeature.basic("admin", "admin"));
|
||||
}
|
||||
|
||||
@Nested
|
||||
class Fetch {
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.commafeed.integration.rest;
|
||||
|
||||
import org.glassfish.jersey.client.JerseyClientBuilder;
|
||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -18,6 +20,11 @@ class FeverIT extends BaseIT {
|
||||
private Long userId;
|
||||
private String apiKey;
|
||||
|
||||
@Override
|
||||
protected JerseyClientBuilder configureClientBuilder(JerseyClientBuilder base) {
|
||||
return base.register(HttpAuthenticationFeature.basic("admin", "admin"));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
// create api key
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test;
|
||||
import com.commafeed.frontend.model.ServerInfo;
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
public class ServerIT extends BaseIT {
|
||||
class ServerIT extends BaseIT {
|
||||
|
||||
@Test
|
||||
void getServerInfos() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.commafeed.integration.servlet;
|
||||
|
||||
import org.glassfish.jersey.client.JerseyClientBuilder;
|
||||
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -12,6 +14,11 @@ import jakarta.ws.rs.core.Response;
|
||||
|
||||
class CustomCodeIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
protected JerseyClientBuilder configureClientBuilder(JerseyClientBuilder base) {
|
||||
return base.register(HttpAuthenticationFeature.basic("admin", "admin"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
// get settings
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.glassfish.jersey.client.ClientProperties;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.commafeed.CommaFeedDropwizardAppExtension;
|
||||
import com.commafeed.frontend.model.UserModel;
|
||||
import com.commafeed.integration.BaseIT;
|
||||
|
||||
@@ -16,12 +15,6 @@ import jakarta.ws.rs.core.Response;
|
||||
|
||||
class LogoutIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
protected CommaFeedDropwizardAppExtension buildExtension() {
|
||||
// override so we don't add http basic auth
|
||||
return new CommaFeedDropwizardAppExtension();
|
||||
}
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
String cookie = login();
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.commafeed.integration.servlet;
|
||||
|
||||
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;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -12,6 +14,11 @@ import jakarta.ws.rs.core.Response;
|
||||
|
||||
class NextUnreadIT extends BaseIT {
|
||||
|
||||
@Override
|
||||
protected JerseyClientBuilder configureClientBuilder(JerseyClientBuilder base) {
|
||||
return base.register(HttpAuthenticationFeature.basic("admin", "admin"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
subscribeAndWaitForEntries(getFeedUrl());
|
||||
|
||||
Reference in New Issue
Block a user