File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments