@@ -84,15 +84,15 @@ func TestPackageContainer(t *testing.T) {
8484 Token string `json:"token"`
8585 }
8686
87- authenticate := []string {`Bearer realm="` + setting .AppURL + `v2/token",service="container_registry",scope="*"` }
87+ defaultAuthenticateValues := []string {`Bearer realm="` + setting .AppURL + `v2/token",service="container_registry",scope="*"` }
8888
8989 t .Run ("Anonymous" , func (t * testing.T ) {
9090 defer tests .PrintCurrentTest (t )()
9191
9292 req := NewRequest (t , "GET" , fmt .Sprintf ("%sv2" , setting .AppURL ))
9393 resp := MakeRequest (t , req , http .StatusUnauthorized )
9494
95- assert .ElementsMatch (t , authenticate , resp .Header ().Values ("WWW-Authenticate" ))
95+ assert .ElementsMatch (t , defaultAuthenticateValues , resp .Header ().Values ("WWW-Authenticate" ))
9696
9797 req = NewRequest (t , "GET" , fmt .Sprintf ("%sv2/token" , setting .AppURL ))
9898 resp = MakeRequest (t , req , http .StatusOK )
@@ -115,6 +115,12 @@ func TestPackageContainer(t *testing.T) {
115115
116116 req = NewRequest (t , "GET" , fmt .Sprintf ("%sv2/token" , setting .AppURL ))
117117 MakeRequest (t , req , http .StatusUnauthorized )
118+
119+ defer test .MockVariableValue (& setting .AppURL , "https://domain:8443/sub-path/" )()
120+ defer test .MockVariableValue (& setting .AppSubURL , "/sub-path" )()
121+ req = NewRequest (t , "GET" , "/v2" )
122+ resp = MakeRequest (t , req , http .StatusUnauthorized )
123+ assert .Equal (t , `Bearer realm="https://domain:8443/v2/token",service="container_registry",scope="*"` , resp .Header ().Get ("WWW-Authenticate" ))
118124 })
119125
120126 t .Run ("User" , func (t * testing.T ) {
@@ -123,7 +129,7 @@ func TestPackageContainer(t *testing.T) {
123129 req := NewRequest (t , "GET" , fmt .Sprintf ("%sv2" , setting .AppURL ))
124130 resp := MakeRequest (t , req , http .StatusUnauthorized )
125131
126- assert .ElementsMatch (t , authenticate , resp .Header ().Values ("WWW-Authenticate" ))
132+ assert .ElementsMatch (t , defaultAuthenticateValues , resp .Header ().Values ("WWW-Authenticate" ))
127133
128134 req = NewRequest (t , "GET" , fmt .Sprintf ("%sv2/token" , setting .AppURL )).
129135 AddBasicAuth (user .Name )
0 commit comments