diff options
Diffstat (limited to 'juick-server/src/test/java/com')
-rw-r--r-- | juick-server/src/test/java/com/juick/server/tests/ServerTests.java | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index 0f483accb..c697ffc60 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -27,18 +27,21 @@ import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.jayway.jsonpath.JsonPath; import com.juick.*; -import com.juick.server.*; -import com.juick.server.api.activity.model.ActivityObject; -import com.juick.service.component.MessageEvent; import com.juick.model.AnonymousUser; import com.juick.model.CommandResult; import com.juick.model.TagStats; +import com.juick.server.*; +import com.juick.server.api.activity.model.Context; +import com.juick.server.api.activity.model.Key; +import com.juick.server.api.activity.model.Person; +import com.juick.server.api.activity.model.activities.Follow; import com.juick.server.util.HttpUtils; import com.juick.server.util.ImageUtils; import com.juick.server.www.Utils; import com.juick.server.xmpp.helpers.XMPPStatus; import com.juick.server.xmpp.s2s.ConnectionIn; import com.juick.service.*; +import com.juick.service.component.MessageEvent; import com.juick.util.DateFormattersHolder; import com.juick.util.MessageUtils; import com.mitchellbosecke.pebble.PebbleEngine; @@ -60,10 +63,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.core.io.ClassPathResource; import org.springframework.http.*; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; @@ -193,6 +194,8 @@ public class ServerTests { private PebbleEngine pebbleEngine; @Value("${ios_app_id:}") private String appId; + @Inject + private SignatureManager signatureManager; private static User ugnich, freefd, juick; static String ugnichName, ugnichPassword, freefdName, freefdPassword, juickName, juickPassword; @@ -1419,17 +1422,17 @@ public class ServerTests { } @Test public void userProfileAndBlogShouldBeExposedAsActivityStream() throws Exception { - mockMvc.perform(get("/u/ugnich").accept(ActivityObject.LD_JSON_MEDIA_TYPE)) + mockMvc.perform(get("/u/ugnich").accept(Context.LD_JSON_MEDIA_TYPE)) .andExpect(status().isOk()) .andExpect(jsonPath("$.icon.url", is("http://localhost:8080/i/a/1.png"))) - .andExpect(jsonPath("$.publicKey.publicKeyPem", is(keystoreManager.getPublicKey()))); + .andExpect(jsonPath("$.publicKey.publicKeyPem", is(keystoreManager.getPublicKeyPem()))); jdbcTemplate.execute("DELETE FROM messages"); List<Integer> mids = IteratorUtils.toList(IntStream.rangeClosed(1, 30) .mapToObj(i -> messagesService.createMessage(ugnich.getUid(), String.format("message %d", i), null, null)) .collect(Collectors.toCollection(ArrayDeque::new)).descendingIterator()); List<Integer> midsPage = mids.stream().limit(20).collect(Collectors.toList()); - mockMvc.perform(get("/u/ugnich/blog").accept(ActivityObject.ACTIVITY_JSON_MEDIA_TYPE)) + mockMvc.perform(get("/u/ugnich/blog").accept(Context.ACTIVITY_JSON_MEDIA_TYPE)) .andExpect(status().isOk()) .andExpect(jsonPath("$.orderedItems", hasSize(20))) .andExpect(jsonPath("$.next", is("http://localhost:8080/u/ugnich/blog?before=" + midsPage.get(midsPage.size() - 1)))); @@ -1676,4 +1679,24 @@ public class ServerTests { .param("hash", userService.getHashByUID(ugnich.getUid())) .param("List-Unsubscribe", "One-Click")).andExpect(status().isOk()); } + @Test + public void ActivityDeserialization() throws IOException { + String followJsonStr = IOUtils.toString(URI.create("classpath:follow.json"), StandardCharsets.UTF_8); + Follow follow = (Follow)jsonMapper.readValue(followJsonStr, Context.class); + String personJsonStr = IOUtils.toString(URI.create("classpath:person.json"), StandardCharsets.UTF_8); + Person person = (Person)jsonMapper.readValue(personJsonStr, Context.class); + } + @Test + public void signingSpec() throws IOException { + Key fromKey = new Key(); + fromKey.setId("to-key-id"); + Person from = new Person(); + from.setPublicKey(fromKey); + Person to = new Person(); + to.setInbox("http://localhost:8080/api/inbox"); + Follow follow = new Follow(); + follow.setActor("http://localhost:8080/u/freefd"); + follow.setObject("http://localhost:8080/u/ugnich"); + signatureManager.post(from, to, follow); + } } |