Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
smatting committed Sep 8, 2022
1 parent 81909e0 commit 75449ac
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/nginz/static/conf/zauth.acl
Expand Up @@ -15,4 +15,4 @@ la (whitelist (path "/notifications")
(path "/assets/v3/**")
(path "/users")
(path "/users/**")
(path "/conversations/*"))
(path "/legalhold/conversations/*"))
3 changes: 3 additions & 0 deletions charts/nginz/values.yaml
Expand Up @@ -397,6 +397,9 @@ nginx_conf:
envs:
- all
doc: true
- path: /legalhold/conversations/(.*)
envs:
- all
- path: /teams$
envs:
- all
Expand Down
1 change: 0 additions & 1 deletion deploy/services-demo/conf/nginz/nginx-docker.conf
Expand Up @@ -247,7 +247,6 @@ http {
proxy_pass http://galley;
}


location /conversations {
include common_response_with_zauth.conf;
proxy_pass http://galley;
Expand Down
5 changes: 5 additions & 0 deletions deploy/services-demo/conf/nginz/nginx.conf
Expand Up @@ -325,6 +325,11 @@ http {
proxy_pass http://galley;
}

location /legalhold/conversations {
return 406;
# include common_response_with_zauth.conf;
# proxy_pass http://galley;
}

location /conversations {
include common_response_with_zauth.conf;
Expand Down
12 changes: 12 additions & 0 deletions libs/wire-api/src/Wire/API/Routes/Public/Galley.hs
Expand Up @@ -185,6 +185,18 @@ type ConversationAPI =
:> Capture "cnv" ConvId
:> Get '[Servant.JSON] Conversation
)
:<|> Named
"get-unqualified-conversation-legalhold-alias"
-- This alias exists, so that it can be uniquely selected in zauth.acl
( Summary "Get a conversation by ID (Legalhold alias)"
:> CanThrow 'ConvNotFound
:> CanThrow 'ConvAccessDenied
:> ZLocalUser
:> "legalhold"
:> "conversations"
:> Capture "cnv" ConvId
:> Get '[Servant.JSON] Conversation
)
:<|> Named
"get-conversation"
( Summary "Get a conversation by ID"
Expand Down
1 change: 1 addition & 0 deletions services/galley/src/Galley/API/Public/Servant.hs
Expand Up @@ -47,6 +47,7 @@ servantSitemap =
where
conversations =
mkNamedAPI @"get-unqualified-conversation" getUnqualifiedConversation
<@> mkNamedAPI @"get-unqualified-conversation-legalhold-alias" getUnqualifiedConversation
<@> mkNamedAPI @"get-conversation" getConversation
<@> mkNamedAPI @"get-conversation-roles" getConversationRoles
<@> mkNamedAPI @"list-conversation-ids-unqualified" conversationIdsPageFromUnqualified
Expand Down
13 changes: 13 additions & 0 deletions services/galley/test/integration/API.hs
Expand Up @@ -63,6 +63,7 @@ import Data.Singletons
import qualified Data.Text as T
import qualified Data.Text.Ascii as Ascii
import Data.Time.Clock (getCurrentTime)
import Debug.Trace
import Federator.Discovery (DiscoveryFailure (..))
import Federator.MockServer (FederatedRequest (..), MockException (..))
import Galley.API.Mapping
Expand Down Expand Up @@ -129,6 +130,7 @@ tests s =
test s "create conversation with remote users" postConvWithRemoteUsersOk,
test s "get empty conversations" getConvsOk,
test s "get conversations by ids" getConvsOk2,
test s "get conversations by ids (legalhold alias)" getConvsOk3,
test s "fail to get >500 conversations" getConvsFailMaxSize,
test s "get conversation ids" getConvIdsOk,
test s "get conversation ids v2" listConvIdsOk,
Expand Down Expand Up @@ -1695,6 +1697,17 @@ getConvsOk2 = do
(Just [])
((\c -> cmOthers (cnvMembers c) \\ cmOthers (cnvMembers expected)) <$> actual)

getConvsOk3 :: TestM ()
getConvsOk3 = do
[alice, bob] <- randomUsers 2
connectUsers alice (singleton bob)
-- create & get one2one conv
cnv1 <- responseJsonError =<< postO2OConv alice bob (Just "gossip1") <!! const 200 === statusCode
res <-
getConvsLHAlias alice (Just $ Left [qUnqualified . cnvQualifiedId $ cnv1]) Nothing <!! do
const 200 === statusCode
traceM (show res)

getConvsFailMaxSize :: TestM ()
getConvsFailMaxSize = do
usr <- randomUser
Expand Down
11 changes: 11 additions & 0 deletions services/galley/test/integration/API/Util.hs
Expand Up @@ -938,6 +938,17 @@ getConvs u r s = do
. zType "access"
. convRange r s

getConvsLHAlias :: UserId -> Maybe (Either [ConvId] ConvId) -> Maybe Int32 -> TestM ResponseLBS
getConvsLHAlias u r s = do
g <- view tsGalley
get $
g
. path "/legalhold/conversations"
. zUser u
. zConn "conn"
. zType "access"
. convRange r s

listConvs :: (MonadIO m, MonadHttp m, HasGalley m) => UserId -> ListConversations -> m ResponseLBS
listConvs u req = do
g <- viewGalley
Expand Down

0 comments on commit 75449ac

Please sign in to comment.