summaryrefslogtreecommitdiffstats
path: root/api/oauth_test.go
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-08-30 21:15:40 -0300
committerGitHub <noreply@github.com>2016-08-30 21:15:40 -0300
commit1326ab66a141e73f1ef7d9d39bb86596f56179e0 (patch)
treeb77723b70bdcfc2bca2ab47580d86eb54a61cd44 /api/oauth_test.go
parente9bc77a8f7f07cb08038e007c52a986cf4b9545b (diff)
downloadchat-1326ab66a141e73f1ef7d9d39bb86596f56179e0.tar.gz
chat-1326ab66a141e73f1ef7d9d39bb86596f56179e0.tar.bz2
chat-1326ab66a141e73f1ef7d9d39bb86596f56179e0.zip
PLT-3984 Add the ability to regenerate OAuth Client Secret (#3899)
Diffstat (limited to 'api/oauth_test.go')
-rw-r--r--api/oauth_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/api/oauth_test.go b/api/oauth_test.go
index 944b1a95b..a54fbc2c3 100644
--- a/api/oauth_test.go
+++ b/api/oauth_test.go
@@ -278,6 +278,30 @@ func TestDeauthorizeApp(t *testing.T) {
}
}
+func TestRegenerateOAuthAppSecret(t *testing.T) {
+ th := Setup().InitSystemAdmin()
+ AdminClient := th.SystemAdminClient
+
+ utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
+
+ app := &model.OAuthApp{Name: "TestApp6" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
+
+ app = AdminClient.Must(AdminClient.RegisterApp(app)).Data.(*model.OAuthApp)
+
+ if regenApp, err := AdminClient.RegenerateOAuthAppSecret(app.Id); err != nil {
+ t.Fatal(err)
+ } else {
+ app2 := regenApp.Data.(*model.OAuthApp)
+ if app2.Id != app.Id {
+ t.Fatal("Should have been the same app Id")
+ }
+
+ if app2.ClientSecret == app.ClientSecret {
+ t.Fatal("Should have been diferent client Secrets")
+ }
+ }
+}
+
func TestOAuthDeleteApp(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
Client := th.BasicClient