Skip to content

Commit

Permalink
Minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
turetske committed Feb 1, 2024
1 parent 6e51b22 commit ea7a9a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion director/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ func registerServeAd(engineCtx context.Context, ctx *gin.Context, sType ServerTy
return
}

adWebUrl, err := url.Parse(ad.WebURL)
adWebUrl, err := url.Parse(adV2.WebURL)
if err != nil && adV2.WebURL != "" { // We allow empty WebURL string for backward compatibility
log.Warningf("Failed to parse server Web URL %v: %v\n", adV2.WebURL, err)
ctx.JSON(http.StatusBadRequest, gin.H{"error": "Invalid server Web URL"})
Expand Down
16 changes: 8 additions & 8 deletions director/redirect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ func TestDirectorRegistration(t *testing.T) {

t.Run("valid-token-V2", func(t *testing.T) {
c, r, w := setupContext()
pKey, token, issuerURL := generateToken(c)
pKey, token, issuerURL := generateToken()
publicKey, err := jwk.PublicKeyOf(pKey)
assert.NoError(t, err, "Error creating public key from private key")

ar := setupMockCache(t, publicKey)
useMockCache(ar, issuerURL)

isurl := url.URL{}
isurl.Path = "https://get-your-tokens.org"
isurl.Path = ts.URL

ad := OriginAdvertiseV2{
DataURL: "https://or-url.org",
Expand Down Expand Up @@ -285,15 +285,15 @@ func TestDirectorRegistration(t *testing.T) {
c, r, w := setupContext()
wrongPrivateKey, err := ecdsa.GenerateKey(elliptic.P521(), rand.Reader)
assert.NoError(t, err, "Error creating another private key")
_, token, issuerURL := generateToken(c)
_, token, issuerURL := generateToken()

wrongPublicKey, err := jwk.PublicKeyOf(wrongPrivateKey)
assert.NoError(t, err, "Error creating public key from private key")
ar := setupMockCache(t, wrongPublicKey)
useMockCache(ar, issuerURL)

isurl := url.URL{}
isurl.Path = "https://get-your-tokens.org"
isurl.Path = ts.URL

ad := OriginAdvertiseV2{Name: "test", DataURL: "https://or-url.org", Namespaces: []NamespaceAdV2{{
Path: "/foo/bar",
Expand Down Expand Up @@ -344,14 +344,14 @@ func TestDirectorRegistration(t *testing.T) {

t.Run("valid-token-with-web-url-V2", func(t *testing.T) {
c, r, w := setupContext()
pKey, token, issuerURL := generateToken(c)
pKey, token, issuerURL := generateToken()
publicKey, err := jwk.PublicKeyOf(pKey)
assert.NoError(t, err, "Error creating public key from private key")
ar := setupMockCache(t, publicKey)
useMockCache(ar, issuerURL)

isurl := url.URL{}
isurl.Path = "https://get-your-tokens.org"
isurl.Path = ts.URL

ad := OriginAdvertiseV2{DataURL: "https://or-url.org", WebURL: "https://localhost:8844", Namespaces: []NamespaceAdV2{{
Path: "/foo/bar",
Expand Down Expand Up @@ -400,14 +400,14 @@ func TestDirectorRegistration(t *testing.T) {

t.Run("valid-token-without-web-url-V2", func(t *testing.T) {
c, r, w := setupContext()
pKey, token, issuerURL := generateToken(c)
pKey, token, issuerURL := generateToken()
publicKey, err := jwk.PublicKeyOf(pKey)
assert.NoError(t, err, "Error creating public key from private key")
ar := setupMockCache(t, publicKey)
useMockCache(ar, issuerURL)

isurl := url.URL{}
isurl.Path = "https://get-your-tokens.org"
isurl.Path = ts.URL

ad := OriginAdvertiseV2{DataURL: "https://or-url.org", Namespaces: []NamespaceAdV2{{Path: "/foo/bar",
Issuer: []TokenIssuer{{IssuerUrl: isurl}}}}}
Expand Down

0 comments on commit ea7a9a7

Please sign in to comment.