From 27ba68a7894d5204b8d75dc7353774977d62fa15 Mon Sep 17 00:00:00 2001 From: Chris Duarte Date: Tue, 28 Nov 2017 11:46:48 -0800 Subject: Add Config to disable Auth Transfers. (#7843) * Add Config to disable Auth Transfers. * Set config ExperimentalEnableAuthenticationTransfer behind an E20 license restriction --- api4/user_test.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'api4/user_test.go') diff --git a/api4/user_test.go b/api4/user_test.go index 0c2b86eda..9c554da54 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -2117,6 +2117,57 @@ func TestSwitchAccount(t *testing.T) { t.Fatal("bad link") } + isLicensed := utils.IsLicensed() + license := utils.License() + enableAuthenticationTransfer := *th.App.Config().ServiceSettings.ExperimentalEnableAuthenticationTransfer + defer func() { + utils.SetIsLicensed(isLicensed) + utils.SetLicense(license) + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ExperimentalEnableAuthenticationTransfer = enableAuthenticationTransfer }) + }() + utils.SetIsLicensed(true) + utils.SetLicense(&model.License{Features: &model.Features{}}) + utils.License().Features.SetDefaults() + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ExperimentalEnableAuthenticationTransfer = false }) + + sr = &model.SwitchRequest{ + CurrentService: model.USER_AUTH_SERVICE_EMAIL, + NewService: model.USER_AUTH_SERVICE_GITLAB, + } + + _, resp = Client.SwitchAccountType(sr) + CheckForbiddenStatus(t, resp) + + th.LoginBasic() + + sr = &model.SwitchRequest{ + CurrentService: model.USER_AUTH_SERVICE_SAML, + NewService: model.USER_AUTH_SERVICE_EMAIL, + Email: th.BasicUser.Email, + NewPassword: th.BasicUser.Password, + } + + _, resp = Client.SwitchAccountType(sr) + CheckForbiddenStatus(t, resp) + + sr = &model.SwitchRequest{ + CurrentService: model.USER_AUTH_SERVICE_EMAIL, + NewService: model.USER_AUTH_SERVICE_LDAP, + } + + _, resp = Client.SwitchAccountType(sr) + CheckForbiddenStatus(t, resp) + + sr = &model.SwitchRequest{ + CurrentService: model.USER_AUTH_SERVICE_LDAP, + NewService: model.USER_AUTH_SERVICE_EMAIL, + } + + _, resp = Client.SwitchAccountType(sr) + CheckForbiddenStatus(t, resp) + + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ExperimentalEnableAuthenticationTransfer = true }) + th.LoginBasic() fakeAuthData := model.NewId() -- cgit v1.2.3-1-g7c22