Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1-api-changes/pr-3213
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Non-binding team endpoints are removed from API version V4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Non-binding team endpoints are removed from API version V4
Remove deprecated non-binding team endpoints from API version V4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this appears in the changelog, it is already in the past. So I prefer past tense or even better "have been removed" (present perfect progressive). But I will not hold my opinion very strongly. :)

5 changes: 3 additions & 2 deletions libs/wire-api/src/Wire/API/Routes/Public/Galley/Team.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import Wire.API.Error.Galley
import Wire.API.Routes.MultiVerb
import Wire.API.Routes.Named
import Wire.API.Routes.Public
import Wire.API.Routes.Version
import Wire.API.Team
import Wire.API.Team.Permission

type TeamAPI =
Named
"create-non-binding-team"
( Summary "Create a new non binding team"
-- FUTUREWORK: deprecated in https://github.com/wireapp/wire-server/pull/2607
:> Until 'V4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe still link the PR and/or ticket? not sure, maybe it's unnecessary noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer less noise.

:> ZUser
:> ZConn
:> CanThrow 'NotConnected
Expand Down Expand Up @@ -69,7 +70,7 @@ type TeamAPI =
:<|> Named
"get-teams"
( Summary "Get teams (deprecated); use `GET /teams/:tid`"
-- FUTUREWORK: deprecated in https://github.com/wireapp/wire-server/pull/2607
:> Until 'V4
:> ZUser
:> "teams"
:> Get '[JSON] TeamList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Wire.API.Routes.LowLevelStream
import Wire.API.Routes.MultiVerb
import Wire.API.Routes.Named
import Wire.API.Routes.Public
import Wire.API.Routes.Version
import Wire.API.Team.Member
import qualified Wire.API.User as User

Expand Down Expand Up @@ -96,7 +97,7 @@ type TeamMemberAPI =
:<|> Named
"add-team-member"
( Summary "Add a new team member"
-- FUTUREWORK: deprecated in https://github.com/wireapp/wire-server/pull/2607
:> Until 'V4
:> CanThrow 'InvalidPermissions
:> CanThrow 'NoAddToBinding
:> CanThrow 'NotATeamMember
Expand Down Expand Up @@ -142,7 +143,7 @@ type TeamMemberAPI =
:<|> Named
"delete-non-binding-team-member"
( Summary "Remove an existing team member"
-- FUTUREWORK: deprecated in https://github.com/wireapp/wire-server/pull/2607
:> Until 'V4
:> CanThrow AuthenticationError
:> CanThrow 'AccessDenied
:> CanThrow 'TeamMemberNotFound
Expand Down
7 changes: 5 additions & 2 deletions libs/wire-api/src/Wire/API/Team.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,18 @@ newTeam tid uid nme ico tb = Team tid uid nme ico Nothing tb DefaultIcon

instance ToSchema Team where
schema =
object "Team" $
objectWithDocModifier "Team" desc $
Team
<$> _teamId .= field "id" schema
<*> _teamCreator .= field "creator" schema
<*> _teamName .= field "name" schema
<*> _teamIcon .= field "icon" schema
<*> _teamIconKey .= maybe_ (optField "icon_key" schema)
<*> _teamBinding .= (fromMaybe Binding <$> optField "binding" schema)
<*> _teamBinding .= (fromMaybe Binding <$> optFieldWithDocModifier "binding" bindingDesc schema)
<*> _teamSplashScreen .= (fromMaybe DefaultIcon <$> optField "splash_screen" schema)
where
desc = description ?~ "`binding` is deprecated, and should be ignored. The non-binding teams API is not used (and will not be supported from API version V4 onwards), and `binding` will always be `true`."
bindingDesc = description ?~ "Deprecated, please ignore."

-- | How a team "binds" its members (users)
--
Expand Down
11 changes: 4 additions & 7 deletions services/brig/test/integration/API/Team.hs
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,8 @@ testCreateTeam brig galley userJournalWatcher = do
email <- randomEmail
usr <- responseJsonError =<< register email newTeam brig
let uid = userId usr
-- Verify that the user is part of exactly one (binding) team
teams <- view teamListTeams <$> getTeams uid galley
liftIO $ assertBool "User not part of exactly one team" (length teams == 1)
let team = fromMaybe (error "No team??") $ listToMaybe teams
let tid = fromMaybe (error "No team??") $ userTeam usr
team <- Team.tdTeam <$> getTeam galley tid
mem <- getTeamMember uid (team ^. teamId) galley
liftIO $ assertBool "Member not part of the team" (uid == mem ^. Member.userId)
-- Verify that the user cannot send invitations before activating their account
Expand Down Expand Up @@ -565,9 +563,8 @@ testCreateTeamPreverified brig galley userJournalWatcher = do
usr <- responseJsonError =<< register' email newTeam c brig <!! const 201 === statusCode
let uid = userId usr
Util.assertUserActivateJournaled userJournalWatcher usr "user activate"
teams <- view teamListTeams <$> getTeams uid galley
liftIO $ assertBool "User not part of exactly one team" (length teams == 1)
let team = fromMaybe (error "No team??") $ listToMaybe teams
let tid = fromMaybe (error "No team??") $ userTeam usr
team <- Team.tdTeam <$> getTeam galley tid
mem <- getTeamMember uid (team ^. teamId) galley
liftIO $ assertBool "Member not part of the team" (uid == mem ^. Member.userId)
team2 <- getTeam galley (team ^. teamId)
Expand Down
16 changes: 1 addition & 15 deletions services/brig/test/integration/API/Team/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,6 @@ deleteTeam g tid u = do
!!! const 202
=== statusCode

getTeams ::
(MonadIO m, MonadCatch m, MonadHttp m, HasCallStack) =>
UserId ->
Galley ->
m TeamList
getTeams u galley =
responseJsonError
=<< get
( galley
. paths ["teams"]
. zAuthAccess u "conn"
. expect2xx
)

newTeam :: BindingNewTeam
newTeam = BindingNewTeam $ newNewTeam (unsafeRange "teamName") DefaultIcon

Expand Down Expand Up @@ -414,7 +400,7 @@ unsuspendTeam brig t =
. paths ["i", "teams", toByteString' t, "unsuspend"]
. contentJson

getTeam :: HasCallStack => Galley -> TeamId -> Http Team.TeamData
getTeam :: (HasCallStack, MonadIO m, MonadHttp m, HasCallStack, MonadCatch m) => Galley -> TeamId -> m Team.TeamData
getTeam galley t =
responseJsonError =<< get (galley . paths ["i", "teams", toByteString' t])

Expand Down
7 changes: 4 additions & 3 deletions services/brig/test/integration/API/UserPendingActivation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

module API.UserPendingActivation where

import API.Team.Util (getTeams)
import API.Team.Util (getTeam)
import Bilge hiding (query)
import Bilge.Assert ((<!!), (===))
import Brig.Options (Opts (..), setTeamInvitationTimeout)
Expand Down Expand Up @@ -60,6 +60,7 @@ import qualified Web.Scim.Schema.Meta as Scim
import qualified Web.Scim.Schema.User as Scim.User
import qualified Web.Scim.Schema.User.Email as Email
import qualified Web.Scim.Schema.User.Phone as Phone
import qualified Wire.API.Routes.Internal.Galley.TeamsIntra as Team
import Wire.API.Team hiding (newTeam)
import Wire.API.Team.Invitation
import Wire.API.User hiding (CreateScimToken)
Expand Down Expand Up @@ -152,7 +153,7 @@ getInvitationByEmail brig email =
newTeam :: BindingNewTeam
newTeam = BindingNewTeam $ newNewTeam (unsafeRange "teamName") DefaultIcon

createUserWithTeamDisableSSO :: (HasCallStack, MonadCatch m, MonadHttp m, MonadIO m, MonadFail m) => Brig -> Galley -> m (UserId, TeamId)
createUserWithTeamDisableSSO :: (HasCallStack, MonadCatch m, MonadHttp m, MonadIO m) => Brig -> Galley -> m (UserId, TeamId)
createUserWithTeamDisableSSO brg gly = do
e <- randomEmail
n <- UUID.toString <$> liftIO UUID.nextRandom
Expand All @@ -166,7 +167,7 @@ createUserWithTeamDisableSSO brg gly = do
]
bdy <- selfUser . responseJsonUnsafe <$> post (brg . path "/i/users" . contentJson . body p)
let (uid, Just tid) = (userId bdy, userTeam bdy)
(team : _) <- (^. teamListTeams) <$> getTeams uid gly
team <- Team.tdTeam <$> getTeam gly tid
() <-
Control.Exception.assert {- "Team ID in registration and team table do not match" -} (tid == team ^. teamId) $
pure ()
Expand Down
6 changes: 5 additions & 1 deletion services/galley/test/integration/API/Teams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import Wire.API.Conversation.Role
import Wire.API.Event.Team
import Wire.API.Internal.Notification hiding (target)
import Wire.API.Routes.Internal.Galley.TeamsIntra as TeamsIntra
import Wire.API.Routes.Version
import Wire.API.Team
import Wire.API.Team.Export (TeamExportUser (..))
import qualified Wire.API.Team.Feature as Public
Expand Down Expand Up @@ -614,9 +615,12 @@ testRemoveBindingTeamMember ownerHasPassword = do
Util.connectUsers owner (List1.singleton mext)
cid1 <- Util.createTeamConv owner tid [mem1 ^. userId, mext] (Just "blaa") Nothing Nothing
when ownerHasPassword $ do
-- request to remove a team member is handled by the by the endpoint do remove non-binding team member
-- which is not supported from V4 onwards, therefore we need to use API version V3
gv3 <- fmap (addPrefixAtVersion V3 .) (view tsUnversionedGalley)
-- Deleting from a binding team with empty body is invalid
delete
( g
( gv3
. paths ["teams", toByteString' tid, "members", toByteString' (mem1 ^. userId)]
. zUser owner
. zConn "conn"
Expand Down
3 changes: 2 additions & 1 deletion services/galley/test/integration/API/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ createBindingTeamWithQualifiedMembers num = do

getTeams :: UserId -> [(ByteString, Maybe ByteString)] -> TestM TeamList
getTeams u queryItems = do
g <- viewGalley
-- This endpoint is removed from version v4 onwards
g <- fmap (addPrefixAtVersion V3 .) (view tsUnversionedGalley)
r <-
get
( g
Expand Down