upgrade dependencies

This commit is contained in:
Athou
2022-01-02 08:22:57 +01:00
parent 3f3ef27d6b
commit 2ee9084b91
3 changed files with 92 additions and 92 deletions

30
pom.xml
View File

@@ -14,7 +14,7 @@
<dropwizard.version>1.3.29</dropwizard.version> <dropwizard.version>1.3.29</dropwizard.version>
<guice.version>4.2.2</guice.version> <guice.version>4.2.2</guice.version>
<querydsl.version>4.2.1</querydsl.version> <querydsl.version>4.2.1</querydsl.version>
<rome.version>1.5.0</rome.version> <rome.version>1.18.0</rome.version>
</properties> </properties>
<scm> <scm>
@@ -249,7 +249,7 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.6</version> <version>1.18.22</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -366,22 +366,22 @@
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.4</version> <version>2.11.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId> <artifactId>commons-collections4</artifactId>
<version>4.1</version> <version>4.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
<version>1.10</version> <version>1.15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId> <artifactId>commons-math3</artifactId>
<version>3.5</version> <version>3.6.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
@@ -426,27 +426,27 @@
<dependency> <dependency>
<groupId>org.jdom</groupId> <groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId> <artifactId>jdom2</artifactId>
<version>2.0.6</version> <version>2.0.6.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.ahocorasick</groupId> <groupId>org.ahocorasick</groupId>
<artifactId>ahocorasick</artifactId> <artifactId>ahocorasick</artifactId>
<version>0.4.0</version> <version>0.6.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.8.3</version> <version>1.14.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ibm.icu</groupId> <groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId> <artifactId>icu4j</artifactId>
<version>55.1</version> <version>70.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sourceforge.cssparser</groupId> <groupId>net.sourceforge.cssparser</groupId>
<artifactId>cssparser</artifactId> <artifactId>cssparser</artifactId>
<version>0.9.16</version> <version>0.9.29</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -464,12 +464,12 @@
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<version>1.4.197</version> <version>2.0.204</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>5.1.42</version> <version>8.0.27</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
@@ -485,13 +485,13 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.13.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>2.0.11-beta</version> <version>2.28.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -28,7 +28,7 @@ import org.jsoup.nodes.Document.OutputSettings;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.nodes.Entities.EscapeMode; import org.jsoup.nodes.Entities.EscapeMode;
import org.jsoup.safety.Cleaner; import org.jsoup.safety.Cleaner;
import org.jsoup.safety.Whitelist; import org.jsoup.safety.Safelist;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import org.w3c.css.sac.InputSource; import org.w3c.css.sac.InputSource;
import org.w3c.dom.css.CSSStyleDeclaration; 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 List<String> ALLOWED_IMG_CSS_RULES = Arrays.asList("display", "width", "height");
private static final char[] FORBIDDEN_CSS_RULE_CHARACTERS = new char[] { '(', ')' }; 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) { public static String truncate(String string, int length) {
if (string != null) { if (string != null) {
@@ -66,8 +66,8 @@ public class FeedUtils {
return string; return string;
} }
private static synchronized Whitelist buildWhiteList() { private static synchronized Safelist buildWhiteList() {
Whitelist whitelist = new Whitelist(); Safelist whitelist = new Safelist();
whitelist.addTags("a", "b", "blockquote", "br", "caption", "cite", "code", "col", "colgroup", "dd", "div", "dl", "dt", "em", "h1", 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", "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"); "table", "tbody", "td", "tfoot", "th", "thead", "tr", "u", "ul");
@@ -504,14 +504,15 @@ public class FeedUtils {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
for (char c : msg.toCharArray()) { for (char c : msg.toCharArray()) {
if (c >= 'a' && c <= 'm') if (c >= 'a' && c <= 'm') {
c += 13; c += 13;
else if (c >= 'n' && c <= 'z') } else if (c >= 'n' && c <= 'z') {
c -= 13; c -= 13;
else if (c >= 'A' && c <= 'M') } else if (c >= 'A' && c <= 'M') {
c += 13; c += 13;
else if (c >= 'N' && c <= 'Z') } else if (c >= 'N' && c <= 'Z') {
c -= 13; c -= 13;
}
message.append(c); message.append(c);
} }

View File

@@ -1,8 +1,14 @@
package com.commafeed.backend.service; package com.commafeed.backend.service;
import com.commafeed.CommaFeedConfiguration; import static org.mockito.ArgumentMatchers.anyString;
import com.commafeed.backend.feed.FeedQueues; import static org.mockito.Mockito.mock;
import com.commafeed.backend.model.Feed; 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.apache.http.HttpHeaders;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@@ -10,95 +16,88 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Answers; import org.mockito.Answers;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.mockserver.client.MockServerClient; import org.mockserver.client.MockServerClient;
import org.mockserver.junit.MockServerRule; import org.mockserver.junit.MockServerRule;
import org.mockserver.model.MediaType; import org.mockserver.model.MediaType;
import static org.mockito.Mockito.*; import com.commafeed.CommaFeedConfiguration;
import static org.mockserver.model.HttpRequest.request; import com.commafeed.backend.feed.FeedQueues;
import static org.mockserver.model.HttpResponse.response; import com.commafeed.backend.model.Feed;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class PubSubServiceTest { public class PubSubServiceTest {
PubSubService underTest; PubSubService underTest;
@Rule @Rule
public MockServerRule mockServerRule = new MockServerRule(this, 22441); public MockServerRule mockServerRule = new MockServerRule(this, 22441);
public MockServerClient mockServerClient; public MockServerClient mockServerClient;
@Mock(answer = Answers.RETURNS_DEEP_STUBS) @Mock(answer = Answers.RETURNS_DEEP_STUBS)
CommaFeedConfiguration config; CommaFeedConfiguration config;
@Mock @Mock
FeedQueues queues; FeedQueues queues;
@Mock @Mock
Feed feed; Feed feed;
@Before
public void init() {
underTest = new PubSubService(config, queues);
@Before // setup feed
public void init() { feed = mock(Feed.class);
underTest = new PubSubService(config, queues); when(feed.getPushHub()).thenReturn("http://localhost:22441/hub");
when(feed.getPushTopic()).thenReturn("foo");
// setup feed // setup config
feed = mock(Feed.class); when(config.getApplicationSettings().getPublicUrl()).thenReturn("http://localhost:22441/hub");
when(feed.getPushHub()).thenReturn("http://localhost:22441/hub"); }
when(feed.getPushTopic()).thenReturn("foo");
// setup config @Test
when(config.getApplicationSettings().getPublicUrl()).thenReturn("http://localhost:22441/hub"); public void subscribe_200() {
} // Arrange
mockServerClient.when(request().withMethod("POST")).respond(response().withStatusCode(200));
@Test // Act
public void subscribe_200() { underTest.subscribe(feed);
// Arrange
mockServerClient
.when(request().withMethod("POST"))
.respond(response().withStatusCode(200));
// Act // Assert
underTest.subscribe(feed); 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 @Test
mockServerClient.verify(request() public void subscribe_400_withPushpressError() {
.withContentType(MediaType.APPLICATION_FORM_URLENCODED) // Arrange
.withHeader(HttpHeaders.USER_AGENT, "CommaFeed") mockServerClient.when(request().withMethod("POST"))
.withMethod("POST") .respond(response().withStatusCode(400).withBody(" is value is not allowed. You may only subscribe to"));
.withPath("/hub"));
verify(feed, never()).setPushTopic(anyString());
verifyZeroInteractions(queues);
}
@Test // Act
public void subscribe_400_withPushpressError() { underTest.subscribe(feed);
// Arrange
mockServerClient
.when(request().withMethod("POST"))
.respond(response().withStatusCode(400).withBody(" is value is not allowed. You may only subscribe to"));
// Act // Assert
underTest.subscribe(feed); verify(feed).setPushTopic(anyString());
verify(queues).giveBack(feed);
}
// Assert @Test
verify(feed).setPushTopic(anyString()); public void subscribe_400_withoutPushpressError() {
verify(queues).giveBack(feed); // Arrange
} mockServerClient.when(request().withMethod("POST")).respond(response().withStatusCode(400));
@Test // Act
public void subscribe_400_withoutPushpressError() { underTest.subscribe(feed);
// Arrange
mockServerClient
.when(request().withMethod("POST"))
.respond(response().withStatusCode(400));
// Act // Assert
underTest.subscribe(feed); verify(feed, never()).setPushTopic(anyString());
verifyZeroInteractions(queues);
// Assert }
verify(feed, never()).setPushTopic(anyString());
verifyZeroInteractions(queues);
}
} }