1
Fork 0

Merge pull request '[gitea] week 2024-48 cherry pick (gitea/main -> forgejo)' (#6062) from earl-warren/wcp/2024-48 into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6062
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
Earl Warren 2024-11-26 16:42:38 +00:00
commit e5417fdede
18 changed files with 287 additions and 146 deletions

View file

@ -5,6 +5,7 @@ package integration
import (
"net/http"
"strings"
"testing"
"code.gitea.io/gitea/modules/setting"
@ -42,7 +43,7 @@ func TestOpenGraphProperties(t *testing.T) {
"og:title": "User Thirty",
"og:url": setting.AppURL + "user30",
"og:type": "profile",
"og:image": "https://secure.gravatar.com/avatar/eae1f44b34ff27284cb0792c7601c89c?d=identicon",
"og:image": "http://localhost:3003/assets/img/avatar_default.png",
"og:site_name": siteName,
},
},
@ -54,7 +55,7 @@ func TestOpenGraphProperties(t *testing.T) {
"og:url": setting.AppURL + "the_34-user.with.all.allowedChars",
"og:description": "some [commonmark](https://commonmark.org/)!",
"og:type": "profile",
"og:image": setting.AppURL + "avatars/avatar34",
"og:image": "http://localhost:3003/assets/img/avatar_default.png",
"og:site_name": siteName,
},
},
@ -66,7 +67,7 @@ func TestOpenGraphProperties(t *testing.T) {
"og:url": setting.AppURL + "user2/repo1/issues/1",
"og:description": "content for the first issue",
"og:type": "object",
"og:image": "https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon",
"og:image": "http://localhost:3003/avatars/ab53a2911ddf9b4817ac01ddcd3d975f",
"og:site_name": siteName,
},
},
@ -78,7 +79,7 @@ func TestOpenGraphProperties(t *testing.T) {
"og:url": setting.AppURL + "user2/repo1/pulls/2",
"og:description": "content for the second issue",
"og:type": "object",
"og:image": "https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon",
"og:image": "http://localhost:3003/avatars/ab53a2911ddf9b4817ac01ddcd3d975f",
"og:site_name": siteName,
},
},
@ -89,7 +90,7 @@ func TestOpenGraphProperties(t *testing.T) {
"og:title": "repo49/test/test.txt at master",
"og:url": setting.AppURL + "/user27/repo49/src/branch/master/test/test.txt",
"og:type": "object",
"og:image": "https://secure.gravatar.com/avatar/7095710e927665f1bdd1ced94152f232?d=identicon",
"og:image": "http://localhost:3003/assets/img/avatar_default.png",
"og:site_name": siteName,
},
},
@ -100,7 +101,7 @@ func TestOpenGraphProperties(t *testing.T) {
"og:title": "Page With Spaced Name",
"og:url": setting.AppURL + "/user2/repo1/wiki/Page-With-Spaced-Name",
"og:type": "object",
"og:image": "https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon",
"og:image": "http://localhost:3003/avatars/ab53a2911ddf9b4817ac01ddcd3d975f",
"og:site_name": siteName,
},
},
@ -111,7 +112,7 @@ func TestOpenGraphProperties(t *testing.T) {
"og:title": "repo1",
"og:url": setting.AppURL + "user2/repo1",
"og:type": "object",
"og:image": "https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon",
"og:image": "http://localhost:3003/avatars/ab53a2911ddf9b4817ac01ddcd3d975f",
"og:site_name": siteName,
},
},
@ -123,7 +124,7 @@ func TestOpenGraphProperties(t *testing.T) {
"og:url": setting.AppURL + "user27/repo49",
"og:description": "A wonderful repository with more than just a README.md",
"og:type": "object",
"og:image": "https://secure.gravatar.com/avatar/7095710e927665f1bdd1ced94152f232?d=identicon",
"og:image": "http://localhost:3003/assets/img/avatar_default.png",
"og:site_name": siteName,
},
},
@ -141,6 +142,10 @@ func TestOpenGraphProperties(t *testing.T) {
assert.True(t, foundProp)
content, foundContent := selection.Attr("content")
assert.True(t, foundContent, "opengraph meta tag without a content property")
if prop == "og:image" {
content = strings.ReplaceAll(content, "http://localhost:3001", "http://localhost:3003")
content = strings.ReplaceAll(content, "http://localhost:3002", "http://localhost:3003")
}
foundProps[prop] = content
})