[MM-39583] - Intermediary web login page: Workspace Cookies (#19256)

* [MM-39583] - Intermediary web login page: Workspace Cookies

* only cloud

* fix error with license check

* feedback impl

* improvement

* make improvements

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Allan Guwatudde
2022-01-12 10:31:46 +03:00
коммит произвёл GitHub
родитель 8ad9a22e77
Коммит 664af506a3
7 изменённых файлов: 115 добавлений и 0 удалений

Просмотреть файл

@@ -3640,6 +3640,46 @@ func TestLoginCookies(t *testing.T) {
})
}
})
t.Run("should return cookie with MMCLOUDURL for cloud installations", func(t *testing.T) {
updateConfig := func(cfg *model.Config) {
*cfg.ServiceSettings.AllowCookiesForSubdomains = true
*cfg.ServiceSettings.SiteURL = "https://testchips.cloud.mattermost.com"
}
th := SetupAndApplyConfigBeforeLogin(t, updateConfig).InitBasic()
defer th.TearDown()
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
_, resp, _ := th.Client.Login(th.BasicUser.Email, th.BasicUser.Password)
val := strings.Split(resp.Header["Set-Cookie"][0], ";")
cloudSessionCookie := strings.Split(val[0], "=")[1]
domain := strings.Split(val[2], "=")[1]
assert.Equal(t, "testchips", cloudSessionCookie)
assert.Equal(t, "mattermost.com", domain)
})
t.Run("should NOT return cookie with MMCLOUDURL for NON cloud installations", func(t *testing.T) {
updateConfig := func(cfg *model.Config) {
*cfg.ServiceSettings.AllowCookiesForSubdomains = true
*cfg.ServiceSettings.SiteURL = "https://testchips.com"
}
th := SetupAndApplyConfigBeforeLogin(t, updateConfig).InitBasic()
defer th.TearDown()
_, resp, _ := th.Client.Login(th.BasicUser.Email, th.BasicUser.Password)
cloudSessionCookie := ""
for _, cookie := range resp.Header["Set-Cookie"] {
if match := regexp.MustCompile("^" + model.SessionCookieCloudUrl + "=([a-z0-9]+)").FindStringSubmatch(cookie); match != nil {
cloudSessionCookie = match[1]
}
}
// no cookie set
assert.Equal(t, "", cloudSessionCookie)
})
}
func TestCBALogin(t *testing.T) {