2019-11-02 14:32:58 +00:00
|
|
|
package suites
|
|
|
|
|
2019-11-24 20:27:59 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2021-04-13 08:38:12 +00:00
|
|
|
"net/url"
|
2019-11-24 20:27:59 +00:00
|
|
|
"testing"
|
2021-11-05 13:14:42 +00:00
|
|
|
|
|
|
|
"github.com/go-rod/rod"
|
2019-11-24 20:27:59 +00:00
|
|
|
)
|
2019-11-02 14:32:58 +00:00
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
func (rs *RodSession) doLogout(t *testing.T, page *rod.Page) {
|
2023-01-12 10:57:44 +00:00
|
|
|
rs.doVisit(t, page, fmt.Sprintf("%s%s", GetLoginBaseURL(BaseDomain), "/logout"))
|
2021-11-05 13:14:42 +00:00
|
|
|
rs.verifyIsFirstFactorPage(t, page)
|
2019-11-02 14:32:58 +00:00
|
|
|
}
|
2021-04-13 08:38:12 +00:00
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
func (rs *RodSession) doLogoutWithRedirect(t *testing.T, page *rod.Page, targetURL string, firstFactor bool) {
|
2023-01-12 10:57:44 +00:00
|
|
|
rs.doVisit(t, page, fmt.Sprintf("%s%s%s", GetLoginBaseURL(BaseDomain), "/logout?rd=", url.QueryEscape(targetURL)))
|
2021-04-13 08:38:12 +00:00
|
|
|
|
|
|
|
if firstFactor {
|
2021-11-05 13:14:42 +00:00
|
|
|
rs.verifyIsFirstFactorPage(t, page)
|
2021-04-13 08:38:12 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
page.MustElementR("h1", "Public resource")
|
|
|
|
|
|
|
|
rs.verifyURLIs(t, page, targetURL)
|
2021-04-13 08:38:12 +00:00
|
|
|
}
|