summaryrefslogtreecommitdiffstats
path: root/api/oauth_test.go
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-08-23 19:06:17 -0300
committerJoram Wilander <jwawilander@gmail.com>2016-08-23 18:06:17 -0400
commit9ab5a7996247c98ed6267b638e1b313e7c4eb8ff (patch)
tree95579883cd48370ee48259b2bec02b124df2f200 /api/oauth_test.go
parente406a92fbbfe36765ab66d9879a9c94546c7c281 (diff)
downloadchat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.tar.gz
chat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.tar.bz2
chat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.zip
PLT-3745 - Deauthorize OAuth Apps (#3852)
* Deauthorize OAuth APIs * Deautorize OAuth Apps Account Settings * Fix typo in client method * Fix issues found by PM * Show help text only when there is at least one authorized app
Diffstat (limited to 'api/oauth_test.go')
-rw-r--r--api/oauth_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/api/oauth_test.go b/api/oauth_test.go
index 47fc342ce..944b1a95b 100644
--- a/api/oauth_test.go
+++ b/api/oauth_test.go
@@ -222,6 +222,62 @@ func TestGetOAuthAppInfo(t *testing.T) {
}
}
+func TestGetAuthorizedApps(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ Client := th.BasicClient
+ AdminClient := th.SystemAdminClient
+
+ utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
+
+ app := &model.OAuthApp{Name: "TestApp5" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
+
+ app = AdminClient.Must(AdminClient.RegisterApp(app)).Data.(*model.OAuthApp)
+
+ if _, err := Client.AllowOAuth(model.AUTHCODE_RESPONSE_TYPE, app.Id, "https://nowhere.com", "user", ""); err != nil {
+ t.Fatal(err)
+ }
+
+ if result, err := Client.GetOAuthAuthorizedApps(); err != nil {
+ t.Fatal(err)
+ } else {
+ apps := result.Data.([]*model.OAuthApp)
+
+ if len(apps) != 1 {
+ t.Fatal("incorrect number of apps should have been 1")
+ }
+ }
+}
+
+func TestDeauthorizeApp(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ Client := th.BasicClient
+ AdminClient := th.SystemAdminClient
+
+ utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
+
+ app := &model.OAuthApp{Name: "TestApp5" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
+
+ app = AdminClient.Must(AdminClient.RegisterApp(app)).Data.(*model.OAuthApp)
+
+ if _, err := Client.AllowOAuth(model.AUTHCODE_RESPONSE_TYPE, app.Id, "https://nowhere.com", "user", ""); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := Client.OAuthDeauthorizeApp(app.Id); err != nil {
+ t.Fatal(err)
+ }
+
+ if result, err := Client.GetOAuthAuthorizedApps(); err != nil {
+ t.Fatal(err)
+ } else {
+ apps := result.Data.([]*model.OAuthApp)
+
+ if len(apps) != 0 {
+ t.Fatal("incorrect number of apps should have been 0")
+ }
+ }
+}
+
func TestOAuthDeleteApp(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
Client := th.BasicClient