Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Oct 5, 2023
1 parent 7bc2a0a commit e81b2a6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
2 changes: 1 addition & 1 deletion director/origin_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestGetRegistryIssuerURL(t *testing.T) {

// Test to make sure the path is as expected
viper.Set("Federation.NamespaceURL", "test-path")
url, err = GetIssuerURL("test-prefix")
url, err = GetRegistryIssuerURL("test-prefix")
assert.Equal(t, nil, err)
assert.Equal(t, "test-path/api/v1.0/registry/test-prefix/.well-known/issuer.jwks", url)

Expand Down
31 changes: 0 additions & 31 deletions director/redirect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,35 +207,4 @@ func TestDirectorRegistration(t *testing.T) {
namaspaceADs = ListNamespacesFromOrigins()
assert.False(t, NamespaceAdContainsPath(namaspaceADs, "/foo/bar"), "Found namespace in the director cache even if the token validation failed.")
serverAds.DeleteAll()

// Repeat again but with bad origin version
wInv = httptest.NewRecorder()
cInv, rInv = gin.CreateTestContext(wInv)
tsInv = httptest.NewServer(http.HandlerFunc(func(wInv http.ResponseWriter, req *http.Request) {
assert.Equal(t, "POST", req.Method, "Not POST Method")
_, err := wInv.Write([]byte(":)"))
assert.NoError(t, err)
}))
defer tsInv.Close()
cInv.Request = &http.Request{
URL: &url.URL{},
}

// Sign token with the good key
signedInv, err = jwt.Sign(tok, jwt.WithKey(jwa.ES512, pKey))
assert.NoError(t, err, "Error signing token")

// Create the request and set the headers
rInv.POST("/", RegisterOrigin)
cInv.Request, _ = http.NewRequest(http.MethodPost, "/", bytes.NewBuffer([]byte(`{"Namespaces": [{"Path": "/foo/bar", "URL": "https://get-your-tokens.org"}]}`)))

cInv.Request.Header.Set("Authorization", "Bearer "+string(signedInv))
cInv.Request.Header.Set("Content-Type", "application/json")
cInv.Request.Header.Set("User-Agent", "pelican-origin/6.0.0")

rInv.ServeHTTP(wInv, cInv.Request)
assert.Equal(t, 500, wInv.Result().StatusCode, "Expected failing status code of 500")
body, _ = io.ReadAll(wInv.Result().Body)
assert.Equal(t, `{"error":"Incompatible versions detected: The director does not support your origin version (6.0.0). Please update to 7.0.0 or newer."}`,
string(body), "Failure wasn't because of version incompatibility")
}
2 changes: 1 addition & 1 deletion xrootd/authorization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestGenerateConfig(t *testing.T) {
issuer, err = GenerateMonitoringIssuer()
require.NoError(t, err)
assert.Equal(t, issuer.Name, "Built-in Monitoring")
assert.Equal(t, issuer.Issuer, "https://"+param.Server_Hostname.GetString()+":"+fmt.Sprint(param.Server_Port.GetInt()))
assert.Equal(t, issuer.Issuer, "https://"+param.Server_Hostname.GetString()+":"+fmt.Sprint(param.Xrootd_Port.GetInt()))
require.Equal(t, len(issuer.BasePaths), 1)
assert.Equal(t, issuer.BasePaths[0], "/pelican/monitoring")
assert.Equal(t, issuer.DefaultUser, "xrootd")
Expand Down

0 comments on commit e81b2a6

Please sign in to comment.