Skip to content

Commit 66f0d51

Browse files
committed
chore: update test for oauthserver
1 parent 396f007 commit 66f0d51

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

internal/api/oauthserver/authorize_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ func TestValidateRequestOriginEdgeCases(t *testing.T) {
136136
tokenService := tokens.NewService(globalConfig, hooksMgr)
137137
server := NewServer(globalConfig, conn, tokenService)
138138

139-
t.Run("Origin with different port should be allowed (hostname matching)", func(t *testing.T) {
139+
t.Run("Origin with different port on non-localhost should be rejected", func(t *testing.T) {
140140
req := httptest.NewRequest(http.MethodGet, "/test", nil)
141141
req.Header.Set("Origin", "https://example.com:8080")
142142

143-
// Should pass because hostname matches (IsRedirectURLValid allows different ports)
143+
// Must be rejected: port mismatch on a non-loopback host.
144+
// RFC 8252 Section 7.3 variable-port exception only applies to localhost.
144145
err := server.validateRequestOrigin(req)
145-
assert.NoError(t, err)
146+
assert.Error(t, err)
147+
assert.Contains(t, err.Error(), "unauthorized request origin")
146148
})
147149

148150
t.Run("Case sensitivity in Origin header", func(t *testing.T) {

0 commit comments

Comments
 (0)