From e81b2a64db701073fe98b10ce97551c6ef8f068b Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Thu, 5 Oct 2023 21:40:09 +0000 Subject: [PATCH] Fix broken tests --- director/origin_api_test.go | 2 +- director/redirect_test.go | 31 ------------------------------- xrootd/authorization_test.go | 2 +- 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/director/origin_api_test.go b/director/origin_api_test.go index ba1f645be..2a2a73fd3 100644 --- a/director/origin_api_test.go +++ b/director/origin_api_test.go @@ -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) diff --git a/director/redirect_test.go b/director/redirect_test.go index 43f10c60d..93d64e02a 100644 --- a/director/redirect_test.go +++ b/director/redirect_test.go @@ -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") } diff --git a/xrootd/authorization_test.go b/xrootd/authorization_test.go index 5180d5a4b..a0831b5c9 100644 --- a/xrootd/authorization_test.go +++ b/xrootd/authorization_test.go @@ -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")