summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e_test.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/e2e_test.go b/test/e2e_test.go
index 19c09af7..218b395d 100644
--- a/test/e2e_test.go
+++ b/test/e2e_test.go
@@ -60,8 +60,23 @@ func TestAuthx(t *testing.T) {
assert.NoError(t, page.Locator("#submit-button").Click())
assert.Contains(t, x.Must(page.Content()), "Received SAML Response")
+ t.Run("generates a usable access token", func(t *testing.T) {
+ rawToken := x.Must(page.Locator("#access-token").TextContent())
+ accessToken := strings.Replace(rawToken, "\"", "", -1)
+ assert.NotEmpty(t, accessToken)
+
+ t.Run("GET http://api.example.com:8080/projects.json", func(t *testing.T) {
+ request := x.Must(http.NewRequestWithContext(t.Context(), "GET", "http://api.example.com:8080/projects.json", nil))
+ request.Header.Add("Authorization", "Bearer "+accessToken)
+ response := x.Must(client.Do(request))
+ require.Equal(t, http.StatusOK, response.StatusCode)
+ projects := x.Must(serde.FromJSON[[]map[string]string](response.Body))
+ assert.NotNil(t, projects)
+ })
+ })
+
t.Run("exchange SAML assertion for access token", func(t *testing.T) {
- samlAssertion := x.Must(page.Locator("#saml-response").TextContent())
+ samlAssertion := x.Must(page.Locator("#raw-saml-response").TextContent())
io := bytes.NewBuffer(nil)
assert.NoError(t, serde.ToJSON(io, map[string]string{
"assertion": samlAssertion,