forked from Archives/Athou_commafeed
upgrade dependencies
This commit is contained in:
30
pom.xml
30
pom.xml
@@ -14,7 +14,7 @@
|
||||
<dropwizard.version>1.3.29</dropwizard.version>
|
||||
<guice.version>4.2.2</guice.version>
|
||||
<querydsl.version>4.2.1</querydsl.version>
|
||||
<rome.version>1.5.0</rome.version>
|
||||
<rome.version>1.18.0</rome.version>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
@@ -249,7 +249,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.6</version>
|
||||
<version>1.18.22</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -366,22 +366,22 @@
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.1</version>
|
||||
<version>4.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.10</version>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>3.5</version>
|
||||
<version>3.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@@ -426,27 +426,27 @@
|
||||
<dependency>
|
||||
<groupId>org.jdom</groupId>
|
||||
<artifactId>jdom2</artifactId>
|
||||
<version>2.0.6</version>
|
||||
<version>2.0.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ahocorasick</groupId>
|
||||
<artifactId>ahocorasick</artifactId>
|
||||
<version>0.4.0</version>
|
||||
<version>0.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.8.3</version>
|
||||
<version>1.14.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ibm.icu</groupId>
|
||||
<artifactId>icu4j</artifactId>
|
||||
<version>55.1</version>
|
||||
<version>70.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.cssparser</groupId>
|
||||
<artifactId>cssparser</artifactId>
|
||||
<version>0.9.16</version>
|
||||
<version>0.9.29</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -464,12 +464,12 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.197</version>
|
||||
<version>2.0.204</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.42</version>
|
||||
<version>8.0.27</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
@@ -485,13 +485,13 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.0.11-beta</version>
|
||||
<version>2.28.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jsoup.nodes.Document.OutputSettings;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.nodes.Entities.EscapeMode;
|
||||
import org.jsoup.safety.Cleaner;
|
||||
import org.jsoup.safety.Whitelist;
|
||||
import org.jsoup.safety.Safelist;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.w3c.css.sac.InputSource;
|
||||
import org.w3c.dom.css.CSSStyleDeclaration;
|
||||
@@ -57,7 +57,7 @@ public class FeedUtils {
|
||||
private static final List<String> ALLOWED_IMG_CSS_RULES = Arrays.asList("display", "width", "height");
|
||||
private static final char[] FORBIDDEN_CSS_RULE_CHARACTERS = new char[] { '(', ')' };
|
||||
|
||||
private static final Whitelist WHITELIST = buildWhiteList();
|
||||
private static final Safelist WHITELIST = buildWhiteList();
|
||||
|
||||
public static String truncate(String string, int length) {
|
||||
if (string != null) {
|
||||
@@ -66,8 +66,8 @@ public class FeedUtils {
|
||||
return string;
|
||||
}
|
||||
|
||||
private static synchronized Whitelist buildWhiteList() {
|
||||
Whitelist whitelist = new Whitelist();
|
||||
private static synchronized Safelist buildWhiteList() {
|
||||
Safelist whitelist = new Safelist();
|
||||
whitelist.addTags("a", "b", "blockquote", "br", "caption", "cite", "code", "col", "colgroup", "dd", "div", "dl", "dt", "em", "h1",
|
||||
"h2", "h3", "h4", "h5", "h6", "i", "iframe", "img", "li", "ol", "p", "pre", "q", "small", "strike", "strong", "sub", "sup",
|
||||
"table", "tbody", "td", "tfoot", "th", "thead", "tr", "u", "ul");
|
||||
@@ -504,14 +504,15 @@ public class FeedUtils {
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
for (char c : msg.toCharArray()) {
|
||||
if (c >= 'a' && c <= 'm')
|
||||
if (c >= 'a' && c <= 'm') {
|
||||
c += 13;
|
||||
else if (c >= 'n' && c <= 'z')
|
||||
} else if (c >= 'n' && c <= 'z') {
|
||||
c -= 13;
|
||||
else if (c >= 'A' && c <= 'M')
|
||||
} else if (c >= 'A' && c <= 'M') {
|
||||
c += 13;
|
||||
else if (c >= 'N' && c <= 'Z')
|
||||
} else if (c >= 'N' && c <= 'Z') {
|
||||
c -= 13;
|
||||
}
|
||||
message.append(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package com.commafeed.backend.service;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.feed.FeedQueues;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockserver.model.HttpRequest.request;
|
||||
import static org.mockserver.model.HttpResponse.response;
|
||||
|
||||
import org.apache.http.HttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -10,95 +16,88 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockserver.client.MockServerClient;
|
||||
import org.mockserver.junit.MockServerRule;
|
||||
import org.mockserver.model.MediaType;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockserver.model.HttpRequest.request;
|
||||
import static org.mockserver.model.HttpResponse.response;
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.feed.FeedQueues;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PubSubServiceTest {
|
||||
|
||||
PubSubService underTest;
|
||||
PubSubService underTest;
|
||||
|
||||
@Rule
|
||||
public MockServerRule mockServerRule = new MockServerRule(this, 22441);
|
||||
public MockServerClient mockServerClient;
|
||||
@Rule
|
||||
public MockServerRule mockServerRule = new MockServerRule(this, 22441);
|
||||
public MockServerClient mockServerClient;
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
CommaFeedConfiguration config;
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
CommaFeedConfiguration config;
|
||||
|
||||
@Mock
|
||||
FeedQueues queues;
|
||||
@Mock
|
||||
FeedQueues queues;
|
||||
|
||||
@Mock
|
||||
Feed feed;
|
||||
@Mock
|
||||
Feed feed;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
underTest = new PubSubService(config, queues);
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
underTest = new PubSubService(config, queues);
|
||||
// setup feed
|
||||
feed = mock(Feed.class);
|
||||
when(feed.getPushHub()).thenReturn("http://localhost:22441/hub");
|
||||
when(feed.getPushTopic()).thenReturn("foo");
|
||||
|
||||
// setup feed
|
||||
feed = mock(Feed.class);
|
||||
when(feed.getPushHub()).thenReturn("http://localhost:22441/hub");
|
||||
when(feed.getPushTopic()).thenReturn("foo");
|
||||
// setup config
|
||||
when(config.getApplicationSettings().getPublicUrl()).thenReturn("http://localhost:22441/hub");
|
||||
}
|
||||
|
||||
// setup config
|
||||
when(config.getApplicationSettings().getPublicUrl()).thenReturn("http://localhost:22441/hub");
|
||||
}
|
||||
@Test
|
||||
public void subscribe_200() {
|
||||
// Arrange
|
||||
mockServerClient.when(request().withMethod("POST")).respond(response().withStatusCode(200));
|
||||
|
||||
@Test
|
||||
public void subscribe_200() {
|
||||
// Arrange
|
||||
mockServerClient
|
||||
.when(request().withMethod("POST"))
|
||||
.respond(response().withStatusCode(200));
|
||||
// Act
|
||||
underTest.subscribe(feed);
|
||||
|
||||
// Act
|
||||
underTest.subscribe(feed);
|
||||
// Assert
|
||||
mockServerClient.verify(request().withContentType(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
.withHeader(HttpHeaders.USER_AGENT, "CommaFeed")
|
||||
.withMethod("POST")
|
||||
.withPath("/hub"));
|
||||
verify(feed, never()).setPushTopic(anyString());
|
||||
verifyZeroInteractions(queues);
|
||||
}
|
||||
|
||||
// Assert
|
||||
mockServerClient.verify(request()
|
||||
.withContentType(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
.withHeader(HttpHeaders.USER_AGENT, "CommaFeed")
|
||||
.withMethod("POST")
|
||||
.withPath("/hub"));
|
||||
verify(feed, never()).setPushTopic(anyString());
|
||||
verifyZeroInteractions(queues);
|
||||
}
|
||||
@Test
|
||||
public void subscribe_400_withPushpressError() {
|
||||
// Arrange
|
||||
mockServerClient.when(request().withMethod("POST"))
|
||||
.respond(response().withStatusCode(400).withBody(" is value is not allowed. You may only subscribe to"));
|
||||
|
||||
@Test
|
||||
public void subscribe_400_withPushpressError() {
|
||||
// Arrange
|
||||
mockServerClient
|
||||
.when(request().withMethod("POST"))
|
||||
.respond(response().withStatusCode(400).withBody(" is value is not allowed. You may only subscribe to"));
|
||||
// Act
|
||||
underTest.subscribe(feed);
|
||||
|
||||
// Act
|
||||
underTest.subscribe(feed);
|
||||
// Assert
|
||||
verify(feed).setPushTopic(anyString());
|
||||
verify(queues).giveBack(feed);
|
||||
}
|
||||
|
||||
// Assert
|
||||
verify(feed).setPushTopic(anyString());
|
||||
verify(queues).giveBack(feed);
|
||||
}
|
||||
@Test
|
||||
public void subscribe_400_withoutPushpressError() {
|
||||
// Arrange
|
||||
mockServerClient.when(request().withMethod("POST")).respond(response().withStatusCode(400));
|
||||
|
||||
@Test
|
||||
public void subscribe_400_withoutPushpressError() {
|
||||
// Arrange
|
||||
mockServerClient
|
||||
.when(request().withMethod("POST"))
|
||||
.respond(response().withStatusCode(400));
|
||||
// Act
|
||||
underTest.subscribe(feed);
|
||||
|
||||
// Act
|
||||
underTest.subscribe(feed);
|
||||
|
||||
// Assert
|
||||
verify(feed, never()).setPushTopic(anyString());
|
||||
verifyZeroInteractions(queues);
|
||||
}
|
||||
// Assert
|
||||
verify(feed, never()).setPushTopic(anyString());
|
||||
verifyZeroInteractions(queues);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user