From cf3a5d8c979b114fceef43b35541b941bcbd62a1 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Mon, 17 Apr 2023 15:00:14 +0300
Subject: Private posts
---
.../java/com/juick/server/tests/ServerTests.java | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)
(limited to 'src/test/java')
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index e97f4a20..e8a90e92 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -71,6 +71,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.text.StringEscapeUtils;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
@@ -2660,4 +2661,27 @@ public class ServerTests {
assertThat(output, is("К вопросу об опросах типа \"За кого бы вы проголосовали\" и \"Согласны ли вы с результатами\"...
\n" +
"Напоминает один старый опрос: опрос на сайте www.$somesite$.ru показал, что 100% Россиян использует интернет."));
}
+ @Test
+ public void messagePrivacyFlow() throws Exception {
+ userService.setPremium(ugnich.getUid(), true);
+ int mid = messagesService.createMessage(ugnich.getUid(), "hidden", "", Collections.emptySet());
+ var msg = messagesService.getMessage(ugnich.getUid(), mid).orElseThrow();
+ assertThat(msg.FriendsOnly, is(false));
+ mockMvc.perform(post("/api/messages/set_privacy?mid=" + mid)
+ .with(httpBasic(ugnichName, ugnichPassword)))
+ .andExpect(status().isOk());
+ msg = messagesService.getMessage(ugnich.getUid(), mid).orElseThrow();
+ assertThat(msg.FriendsOnly, is(true));
+ var res = commandsManager.processCommand(freefd, String.format("#%d reply", mid), emptyUri);
+ assertThat(res.getNewMessage(), is(Optional.empty()));
+ mockMvc.perform(post("/api/messages/set_privacy?mid=" + mid)
+ .with(httpBasic(ugnichName, ugnichPassword)))
+ .andExpect(status().isOk());
+ msg = messagesService.getMessage(ugnich.getUid(), mid).orElseThrow();
+ assertThat(msg.FriendsOnly, is(false));
+ userService.setPremium(ugnich.getUid(), false);
+ mockMvc.perform(post("/api/messages/set_privacy?mid=" + mid)
+ .with(httpBasic(ugnichName, ugnichPassword)))
+ .andExpect(status().isBadRequest());
+ }
}
--
cgit v1.2.3