-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
fba266f
commit 9481a88
Showing
9 changed files
with
124 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Adds a field which contains a list of all active sessions to each OAuth application in the response of `GET /oauth/applications` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Test.OAuth where | ||
|
||
import API.Brig | ||
import API.BrigInternal | ||
import Data.String.Conversions | ||
import Network.HTTP.Types | ||
import Network.URI | ||
import SetupHelpers | ||
import Testlib.Prelude | ||
|
||
testListApplicationsWithActiveSessions :: (HasCallStack) => App () | ||
testListApplicationsWithActiveSessions = do | ||
user <- randomUser OwnDomain def | ||
oauthClient <- createOAuthClient user "foobar" "https://example.com" >>= getJSON 200 | ||
cid <- oauthClient %. "client_id" | ||
let scopes = ["write:conversations"] | ||
let generateAccessToken = do | ||
authCodeResponse <- generateOAuthAuthorizationCode user cid scopes "https://example.com" | ||
let location = fromMaybe (error "no location header") $ parseURI . cs . snd =<< locationHeader authCodeResponse | ||
let code = maybe "no code query param" cs $ join $ lookup (cs "code") $ parseQuery $ cs location.uriQuery | ||
void $ createOAuthAccessToken user cid code "https://example.com" >>= getJSON 200 | ||
replicateM_ 2 generateAccessToken | ||
[app] <- getOAuthApplications user >>= getJSON 200 >>= asList | ||
sessions <- app %. "sessions" >>= asList | ||
length sessions `shouldMatchInt` 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters