@@ -84,15 +84,15 @@ func TestPackageContainer(t *testing.T) {
84
84
Token string `json:"token"`
85
85
}
86
86
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="*"` }
88
88
89
89
t .Run ("Anonymous" , func (t * testing.T ) {
90
90
defer tests .PrintCurrentTest (t )()
91
91
92
92
req := NewRequest (t , "GET" , fmt .Sprintf ("%sv2" , setting .AppURL ))
93
93
resp := MakeRequest (t , req , http .StatusUnauthorized )
94
94
95
- assert .ElementsMatch (t , authenticate , resp .Header ().Values ("WWW-Authenticate" ))
95
+ assert .ElementsMatch (t , defaultAuthenticateValues , resp .Header ().Values ("WWW-Authenticate" ))
96
96
97
97
req = NewRequest (t , "GET" , fmt .Sprintf ("%sv2/token" , setting .AppURL ))
98
98
resp = MakeRequest (t , req , http .StatusOK )
@@ -115,6 +115,12 @@ func TestPackageContainer(t *testing.T) {
115
115
116
116
req = NewRequest (t , "GET" , fmt .Sprintf ("%sv2/token" , setting .AppURL ))
117
117
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" ))
118
124
})
119
125
120
126
t .Run ("User" , func (t * testing.T ) {
@@ -123,7 +129,7 @@ func TestPackageContainer(t *testing.T) {
123
129
req := NewRequest (t , "GET" , fmt .Sprintf ("%sv2" , setting .AppURL ))
124
130
resp := MakeRequest (t , req , http .StatusUnauthorized )
125
131
126
- assert .ElementsMatch (t , authenticate , resp .Header ().Values ("WWW-Authenticate" ))
132
+ assert .ElementsMatch (t , defaultAuthenticateValues , resp .Header ().Values ("WWW-Authenticate" ))
127
133
128
134
req = NewRequest (t , "GET" , fmt .Sprintf ("%sv2/token" , setting .AppURL )).
129
135
AddBasicAuth (user .Name )
0 commit comments