|
| 1 | +// Copyright 2025 The Gitea Authors. All rights reserved. |
| 2 | +// SPDX-License-Identifier: MIT |
| 3 | +package feed_test |
| 4 | + |
| 5 | +import ( |
| 6 | + "testing" |
| 7 | + |
| 8 | + "code.gitea.io/gitea/models/unittest" |
| 9 | + user_model "code.gitea.io/gitea/models/user" |
| 10 | + "code.gitea.io/gitea/routers/web/feed" |
| 11 | + "code.gitea.io/gitea/services/contexttest" |
| 12 | + "github.com/stretchr/testify/assert" |
| 13 | +) |
| 14 | + |
| 15 | +func TestMain(m *testing.M) { |
| 16 | + unittest.MainTest(m) |
| 17 | +} |
| 18 | + |
| 19 | +func TestCheckGetOrgFeedsAsOrgMember(t *testing.T) { |
| 20 | + unittest.PrepareTestEnv(t) |
| 21 | + ctx, resp := contexttest.MockContext(t, "org3.atom") |
| 22 | + ctx.ContextUser = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}) |
| 23 | + contexttest.LoadUser(t, ctx, 2) |
| 24 | + ctx.IsSigned = true |
| 25 | + |
| 26 | + feed.ShowUserFeedAtom(ctx) |
| 27 | + assert.Contains(t, resp.Body.String(), "<entry>") // Should contain 1 private entry |
| 28 | +} |
| 29 | + |
| 30 | +func TestCheckGetOrgFeedsAsNonOrgMember(t *testing.T) { |
| 31 | + unittest.PrepareTestEnv(t) |
| 32 | + ctx, resp := contexttest.MockContext(t, "org3.atom") |
| 33 | + ctx.ContextUser = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}) |
| 34 | + contexttest.LoadUser(t, ctx, 5) |
| 35 | + ctx.IsSigned = true |
| 36 | + |
| 37 | + feed.ShowUserFeedAtom(ctx) |
| 38 | + assert.NotContains(t, resp.Body.String(), "<entry>") // Should not contain any entries |
| 39 | +} |
0 commit comments