diff options
| author | mo khan <mo@mokhan.ca> | 2025-06-18 14:42:36 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-06-18 14:42:36 -0600 |
| commit | 011fe0f9af046235cc25e87aaf25398db125a79f (patch) | |
| tree | 698c1570ccc8cd26cdf580858d584bb11f44d284 /pkg/sts/server_test.go | |
| parent | 7db38ae743b025546202ea32651ad40a0c3c7d77 (diff) | |
Create a token creation endpointsts
Diffstat (limited to 'pkg/sts/server_test.go')
| -rw-r--r-- | pkg/sts/server_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/sts/server_test.go b/pkg/sts/server_test.go index ad8ff28..9c54475 100644 --- a/pkg/sts/server_test.go +++ b/pkg/sts/server_test.go @@ -2,13 +2,20 @@ package sts import ( "net/http" + "strconv" "testing" + "time" + "github.com/oauth2-proxy/mockoidc" "github.com/stretchr/testify/assert" "github.com/xlgmokha/x/pkg/test" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web" ) func TestServer(t *testing.T) { + srv := web.NewOIDCServer(t) + defer srv.Close() + t.Run("New", func(t *testing.T) { server := New(t.Context()) @@ -18,5 +25,17 @@ func TestServer(t *testing.T) { server.ServeHTTP(w, r) assert.Equal(t, http.StatusNotFound, w.Code) }) + + t.Run("POST /oauth/token", func(t *testing.T) { + code := strconv.FormatInt(time.Now().Unix(), 10) + user := mockoidc.DefaultUser() + srv.MockOIDC.QueueUser(user) + srv.MockOIDC.QueueCode(code) + + r, w := test.RequestResponse("POST", "/oauth/token") + + server.ServeHTTP(w, r) + assert.Equal(t, http.StatusCreated, w.Code) + }) }) } |
