merge: upstream
This commit is contained in:
commit
5db583a3eb
701 changed files with 50809 additions and 13660 deletions
|
@ -7,7 +7,7 @@ services:
|
|||
- "127.0.0.1:56312:6379"
|
||||
|
||||
dbtest:
|
||||
image: postgres:13
|
||||
image: postgres:15
|
||||
ports:
|
||||
- "127.0.0.1:54312:5432"
|
||||
environment:
|
||||
|
|
|
@ -93,7 +93,7 @@ describe('Webリソース', () => {
|
|||
});
|
||||
aliceChannel = await channel(alice, {});
|
||||
|
||||
bob = await signup({ username: 'alice' });
|
||||
bob = await signup({ username: 'bob' });
|
||||
}, 1000 * 60 * 2);
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -152,6 +152,11 @@ describe('Webリソース', () => {
|
|||
type,
|
||||
}));
|
||||
|
||||
test('がGETできる。(ノートが存在しない場合でも。)', async () => await ok({
|
||||
path: path(bob.username),
|
||||
type,
|
||||
}));
|
||||
|
||||
test('は存在しないユーザーはGETできない。', async () => await notOk({
|
||||
path: path('nonexisting'),
|
||||
status: 404,
|
||||
|
|
|
@ -26,9 +26,10 @@ describe('FF visibility', () => {
|
|||
await app.close();
|
||||
});
|
||||
|
||||
test('ffVisibility が public なユーザーのフォロー/フォロワーを誰でも見れる', async () => {
|
||||
test('followingVisibility, followersVisibility がともに public なユーザーのフォロー/フォロワーを誰でも見れる', async () => {
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'public',
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
|
@ -44,9 +45,88 @@ describe('FF visibility', () => {
|
|||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
});
|
||||
|
||||
test('ffVisibility が followers なユーザーのフォロー/フォロワーを自分で見れる', async () => {
|
||||
test('followingVisibility が public であれば followersVisibility の設定に関わらずユーザーのフォローを誰でも見れる', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('followersVisibility が public であれば followingVisibility の設定に関わらずユーザーのフォロワーを誰でも見れる', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('followingVisibility, followersVisibility がともに followers なユーザーのフォロー/フォロワーを自分で見れる', async () => {
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'followers',
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
|
@ -62,9 +142,88 @@ describe('FF visibility', () => {
|
|||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
});
|
||||
|
||||
test('ffVisibility が followers なユーザーのフォロー/フォロワーを非フォロワーが見れない', async () => {
|
||||
test('followingVisibility が followers なユーザーのフォローを followersVisibility の設定に関わらず自分で見れる', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('followersVisibility が followers なユーザーのフォロワーを followingVisibility の設定に関わらず自分で見れる', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('followingVisibility, followersVisibility がともに followers なユーザーのフォロー/フォロワーを非フォロワーが見れない', async () => {
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'followers',
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
|
@ -78,9 +237,82 @@ describe('FF visibility', () => {
|
|||
assert.strictEqual(followersRes.status, 400);
|
||||
});
|
||||
|
||||
test('ffVisibility が followers なユーザーのフォロー/フォロワーをフォロワーが見れる', async () => {
|
||||
test('followingVisibility が followers なユーザーのフォローを followersVisibility の設定に関わらず非フォロワーが見れない', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 400);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 400);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 400);
|
||||
}
|
||||
});
|
||||
|
||||
test('followersVisibility が followers なユーザーのフォロワーを followingVisibility の設定に関わらず非フォロワーが見れない', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 400);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 400);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 400);
|
||||
}
|
||||
});
|
||||
|
||||
test('followingVisibility, followersVisibility がともに followers なユーザーのフォロー/フォロワーをフォロワーが見れる', async () => {
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'followers',
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
await api('/following/create', {
|
||||
|
@ -100,9 +332,106 @@ describe('FF visibility', () => {
|
|||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
});
|
||||
|
||||
test('ffVisibility が private なユーザーのフォロー/フォロワーを自分で見れる', async () => {
|
||||
test('followingVisibility が followers なユーザーのフォローを followersVisibility の設定に関わらずフォロワーが見れる', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
await api('/following/create', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
await api('/following/create', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
await api('/following/create', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('followersVisibility が followers なユーザーのフォロワーを followingVisibility の設定に関わらずフォロワーが見れる', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
await api('/following/create', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
await api('/following/create', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
await api('/following/create', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('followingVisibility, followersVisibility がともに private なユーザーのフォロー/フォロワーを自分で見れる', async () => {
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'private',
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
|
@ -118,9 +447,88 @@ describe('FF visibility', () => {
|
|||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
});
|
||||
|
||||
test('ffVisibility が private なユーザーのフォロー/フォロワーを他人が見れない', async () => {
|
||||
test('followingVisibility が private なユーザーのフォローを followersVisibility の設定に関わらず自分で見れる', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followingRes.body), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('followersVisibility が private なユーザーのフォロワーを followingVisibility の設定に関わらず自分で見れる', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, alice);
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
assert.strictEqual(Array.isArray(followersRes.body), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('followingVisibility, followersVisibility がともに private なユーザーのフォロー/フォロワーを他人が見れない', async () => {
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'private',
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
|
@ -134,36 +542,129 @@ describe('FF visibility', () => {
|
|||
assert.strictEqual(followersRes.status, 400);
|
||||
});
|
||||
|
||||
test('followingVisibility が private なユーザーのフォローを followersVisibility の設定に関わらず他人が見れない', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 400);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 400);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await api('/users/following', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followingRes.status, 400);
|
||||
}
|
||||
});
|
||||
|
||||
test('followersVisibility が private なユーザーのフォロワーを followingVisibility の設定に関わらず他人が見れない', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'public',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 400);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 400);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await api('/users/followers', {
|
||||
userId: alice.id,
|
||||
}, bob);
|
||||
assert.strictEqual(followersRes.status, 400);
|
||||
}
|
||||
});
|
||||
|
||||
describe('AP', () => {
|
||||
test('ffVisibility が public 以外ならばAPからは取得できない', async () => {
|
||||
test('followingVisibility が public 以外ならばAPからはフォローを取得できない', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'public',
|
||||
followingVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await simpleGet(`/users/${alice.id}/following`, 'application/activity+json');
|
||||
const followersRes = await simpleGet(`/users/${alice.id}/followers`, 'application/activity+json');
|
||||
assert.strictEqual(followingRes.status, 200);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await simpleGet(`/users/${alice.id}/following`, 'application/activity+json');
|
||||
assert.strictEqual(followingRes.status, 403);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
followingVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await simpleGet(`/users/${alice.id}/following`, 'application/activity+json');
|
||||
assert.strictEqual(followingRes.status, 403);
|
||||
}
|
||||
});
|
||||
|
||||
test('followersVisibility が public 以外ならばAPからはフォロワーを取得できない', async () => {
|
||||
{
|
||||
await api('/i/update', {
|
||||
followersVisibility: 'public',
|
||||
}, alice);
|
||||
|
||||
const followersRes = await simpleGet(`/users/${alice.id}/followers`, 'application/activity+json');
|
||||
assert.strictEqual(followersRes.status, 200);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'followers',
|
||||
followersVisibility: 'followers',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await simpleGet(`/users/${alice.id}/following`, 'application/activity+json');
|
||||
const followersRes = await simpleGet(`/users/${alice.id}/followers`, 'application/activity+json');
|
||||
assert.strictEqual(followingRes.status, 403);
|
||||
assert.strictEqual(followersRes.status, 403);
|
||||
}
|
||||
{
|
||||
await api('/i/update', {
|
||||
ffVisibility: 'private',
|
||||
followersVisibility: 'private',
|
||||
}, alice);
|
||||
|
||||
const followingRes = await simpleGet(`/users/${alice.id}/following`, 'application/activity+json');
|
||||
const followersRes = await simpleGet(`/users/${alice.id}/followers`, 'application/activity+json');
|
||||
assert.strictEqual(followingRes.status, 403);
|
||||
assert.strictEqual(followersRes.status, 403);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ process.env.NODE_ENV = 'test';
|
|||
|
||||
import * as assert from 'assert';
|
||||
import { MiFollowing } from '@/models/Following.js';
|
||||
import { connectStream, signup, api, post, startServer, initTestDb, waitFire } from '../utils.js';
|
||||
import { signup, api, post, startServer, initTestDb, waitFire } from '../utils.js';
|
||||
import type { INestApplicationContext } from '@nestjs/common';
|
||||
import type * as misskey from 'misskey-js';
|
||||
|
||||
|
@ -34,12 +34,16 @@ describe('Streaming', () => {
|
|||
let ayano: misskey.entities.MeSignup;
|
||||
let kyoko: misskey.entities.MeSignup;
|
||||
let chitose: misskey.entities.MeSignup;
|
||||
let kanako: misskey.entities.MeSignup;
|
||||
|
||||
// Remote users
|
||||
let akari: misskey.entities.MeSignup;
|
||||
let chinatsu: misskey.entities.MeSignup;
|
||||
let takumi: misskey.entities.MeSignup;
|
||||
|
||||
let kyokoNote: any;
|
||||
let kanakoNote: any;
|
||||
let takumiNote: any;
|
||||
let list: any;
|
||||
|
||||
beforeAll(async () => {
|
||||
|
@ -50,11 +54,15 @@ describe('Streaming', () => {
|
|||
ayano = await signup({ username: 'ayano' });
|
||||
kyoko = await signup({ username: 'kyoko' });
|
||||
chitose = await signup({ username: 'chitose' });
|
||||
kanako = await signup({ username: 'kanako' });
|
||||
|
||||
akari = await signup({ username: 'akari', host: 'example.com' });
|
||||
chinatsu = await signup({ username: 'chinatsu', host: 'example.com' });
|
||||
takumi = await signup({ username: 'takumi', host: 'example.com' });
|
||||
|
||||
kyokoNote = await post(kyoko, { text: 'foo' });
|
||||
kanakoNote = await post(kanako, { text: 'hoge' });
|
||||
takumiNote = await post(takumi, { text: 'piyo' });
|
||||
|
||||
// Follow: ayano => kyoko
|
||||
await api('following/create', { userId: kyoko.id }, ayano);
|
||||
|
@ -62,6 +70,9 @@ describe('Streaming', () => {
|
|||
// Follow: ayano => akari
|
||||
await follow(ayano, akari);
|
||||
|
||||
// Mute: chitose => kanako
|
||||
await api('mute/create', { userId: kanako.id }, chitose);
|
||||
|
||||
// List: chitose => ayano, kyoko
|
||||
list = await api('users/lists/create', {
|
||||
name: 'my list',
|
||||
|
@ -76,6 +87,11 @@ describe('Streaming', () => {
|
|||
listId: list.id,
|
||||
userId: kyoko.id,
|
||||
}, chitose);
|
||||
|
||||
await api('users/lists/push', {
|
||||
listId: list.id,
|
||||
userId: takumi.id,
|
||||
}, chitose);
|
||||
}, 1000 * 60 * 2);
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -452,6 +468,96 @@ describe('Streaming', () => {
|
|||
|
||||
assert.strictEqual(fired, false);
|
||||
});
|
||||
|
||||
// #10443
|
||||
test('チャンネル投稿は流れない', async () => {
|
||||
// リスインしている kyoko が 任意のチャンネルに投降した時の動きを見たい
|
||||
const fired = await waitFire(
|
||||
chitose, 'userList',
|
||||
() => api('notes/create', { text: 'foo', channelId: 'dummy' }, kyoko),
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id,
|
||||
{ listId: list.id },
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, false);
|
||||
});
|
||||
|
||||
// #10443
|
||||
test('ミュートしているユーザへのリプライがリストTLに流れない', async () => {
|
||||
// chitose が kanako をミュートしている状態で、リスインしている kyoko が kanako にリプライした時の動きを見たい
|
||||
const fired = await waitFire(
|
||||
chitose, 'userList',
|
||||
() => api('notes/create', { text: 'foo', replyId: kanakoNote.id }, kyoko),
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id,
|
||||
{ listId: list.id },
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, false);
|
||||
});
|
||||
|
||||
// #10443
|
||||
test('ミュートしているユーザの投稿をリノートしたときリストTLに流れない', async () => {
|
||||
// chitose が kanako をミュートしている状態で、リスインしている kyoko が kanako のノートをリノートした時の動きを見たい
|
||||
const fired = await waitFire(
|
||||
chitose, 'userList',
|
||||
() => api('notes/create', { renoteId: kanakoNote.id }, kyoko),
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id,
|
||||
{ listId: list.id },
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, false);
|
||||
});
|
||||
|
||||
// #10443
|
||||
test('ミュートしているサーバのノートがリストTLに流れない', async () => {
|
||||
await api('/i/update', {
|
||||
mutedInstances: ['example.com'],
|
||||
}, chitose);
|
||||
|
||||
// chitose が example.com をミュートしている状態で、リスインしている takumi が ノートした時の動きを見たい
|
||||
const fired = await waitFire(
|
||||
chitose, 'userList',
|
||||
() => api('notes/create', { text: 'foo' }, takumi),
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id,
|
||||
{ listId: list.id },
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, false);
|
||||
});
|
||||
|
||||
// #10443
|
||||
test('ミュートしているサーバのノートに対するリプライがリストTLに流れない', async () => {
|
||||
await api('/i/update', {
|
||||
mutedInstances: ['example.com'],
|
||||
}, chitose);
|
||||
|
||||
// chitose が example.com をミュートしている状態で、リスインしている kyoko が takumi のノートにリプライした時の動きを見たい
|
||||
const fired = await waitFire(
|
||||
chitose, 'userList',
|
||||
() => api('notes/create', { text: 'foo', replyId: takumiNote.id }, kyoko),
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id,
|
||||
{ listId: list.id },
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, false);
|
||||
});
|
||||
|
||||
// #10443
|
||||
test('ミュートしているサーバのノートに対するリノートがリストTLに流れない', async () => {
|
||||
await api('/i/update', {
|
||||
mutedInstances: ['example.com'],
|
||||
}, chitose);
|
||||
|
||||
// chitose が example.com をミュートしている状態で、リスインしている kyoko が takumi のノートをリノートした時の動きを見たい
|
||||
const fired = await waitFire(
|
||||
chitose, 'userList',
|
||||
() => api('notes/create', { renoteId: takumiNote.id }, kyoko),
|
||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id,
|
||||
{ listId: list.id },
|
||||
);
|
||||
|
||||
assert.strictEqual(fired, false);
|
||||
});
|
||||
});
|
||||
|
||||
// XXX: QueryFailedError: duplicate key value violates unique constraint "IDX_347fec870eafea7b26c8a73bac"
|
||||
|
|
|
@ -10,9 +10,8 @@ process.env.NODE_ENV = 'test';
|
|||
process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING = 'true';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { signup, api, post, react, startServer, waitFire, sleep, uploadUrl, randomString } from '../utils.js';
|
||||
import { api, post, randomString, signup, sleep, startServer, uploadUrl } from '../utils.js';
|
||||
import type { INestApplicationContext } from '@nestjs/common';
|
||||
import type * as misskey from 'misskey-js';
|
||||
|
||||
function genHost() {
|
||||
return randomString() + '.example.com';
|
||||
|
@ -366,8 +365,8 @@ describe('Timelines', () => {
|
|||
await api('/following/create', { userId: bob.id }, alice);
|
||||
await sleep(1000);
|
||||
const [bobFile, carolFile] = await Promise.all([
|
||||
uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/icon.png'),
|
||||
uploadUrl(carol, 'https://raw.githubusercontent.com/misskey-dev/assets/main/icon.png'),
|
||||
uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/public/icon.png'),
|
||||
uploadUrl(carol, 'https://raw.githubusercontent.com/misskey-dev/assets/main/public/icon.png'),
|
||||
]);
|
||||
const bobNote1 = await post(bob, { text: 'hi' });
|
||||
const bobNote2 = await post(bob, { fileIds: [bobFile.id] });
|
||||
|
@ -666,7 +665,7 @@ describe('Timelines', () => {
|
|||
test.concurrent('[withFiles: true] ファイル付きノートのみ含まれる', async () => {
|
||||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/icon.png');
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/public/icon.png');
|
||||
const bobNote1 = await post(bob, { text: 'hi' });
|
||||
const bobNote2 = await post(bob, { fileIds: [file.id] });
|
||||
|
||||
|
@ -804,7 +803,7 @@ describe('Timelines', () => {
|
|||
test.concurrent('[withFiles: true] ファイル付きノートのみ含まれる', async () => {
|
||||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/icon.png');
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/public/icon.png');
|
||||
const bobNote1 = await post(bob, { text: 'hi' });
|
||||
const bobNote2 = await post(bob, { fileIds: [file.id] });
|
||||
|
||||
|
@ -999,7 +998,7 @@ describe('Timelines', () => {
|
|||
|
||||
const list = await api('/users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
||||
await api('/users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/icon.png');
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/public/icon.png');
|
||||
const bobNote1 = await post(bob, { text: 'hi' });
|
||||
const bobNote2 = await post(bob, { fileIds: [file.id] });
|
||||
|
||||
|
@ -1158,7 +1157,7 @@ describe('Timelines', () => {
|
|||
test.concurrent('[withFiles: true] ファイル付きノートのみ含まれる', async () => {
|
||||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/icon.png');
|
||||
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/public/icon.png');
|
||||
const bobNote1 = await post(bob, { text: 'hi' });
|
||||
const bobNote2 = await post(bob, { fileIds: [file.id] });
|
||||
|
||||
|
|
|
@ -115,7 +115,8 @@ describe('ユーザー', () => {
|
|||
pinnedPageId: user.pinnedPageId,
|
||||
pinnedPage: user.pinnedPage,
|
||||
publicReactions: user.publicReactions,
|
||||
ffVisibility: user.ffVisibility,
|
||||
followingVisibility: user.followingVisibility,
|
||||
followersVisibility: user.followersVisibility,
|
||||
twoFactorEnabled: user.twoFactorEnabled,
|
||||
usePasswordLessLogin: user.usePasswordLessLogin,
|
||||
securityKeys: user.securityKeys,
|
||||
|
@ -171,6 +172,7 @@ describe('ユーザー', () => {
|
|||
hasPendingReceivedFollowRequest: user.hasPendingReceivedFollowRequest,
|
||||
unreadAnnouncements: user.unreadAnnouncements,
|
||||
mutedWords: user.mutedWords,
|
||||
hardMutedWords: user.hardMutedWords,
|
||||
mutedInstances: user.mutedInstances,
|
||||
mutingNotificationTypes: user.mutingNotificationTypes,
|
||||
notificationRecieveConfig: user.notificationRecieveConfig,
|
||||
|
@ -391,7 +393,8 @@ describe('ユーザー', () => {
|
|||
assert.strictEqual(response.pinnedPageId, null);
|
||||
assert.strictEqual(response.pinnedPage, null);
|
||||
assert.strictEqual(response.publicReactions, true);
|
||||
assert.strictEqual(response.ffVisibility, 'public');
|
||||
assert.strictEqual(response.followingVisibility, 'public');
|
||||
assert.strictEqual(response.followersVisibility, 'public');
|
||||
assert.strictEqual(response.twoFactorEnabled, false);
|
||||
assert.strictEqual(response.usePasswordLessLogin, false);
|
||||
assert.strictEqual(response.securityKeys, false);
|
||||
|
@ -502,9 +505,12 @@ describe('ユーザー', () => {
|
|||
{ parameters: (): object => ({ alwaysMarkNsfw: false }) },
|
||||
{ parameters: (): object => ({ autoSensitive: true }) },
|
||||
{ parameters: (): object => ({ autoSensitive: false }) },
|
||||
{ parameters: (): object => ({ ffVisibility: 'private' }) },
|
||||
{ parameters: (): object => ({ ffVisibility: 'followers' }) },
|
||||
{ parameters: (): object => ({ ffVisibility: 'public' }) },
|
||||
{ parameters: (): object => ({ followingVisibility: 'private' }) },
|
||||
{ parameters: (): object => ({ followingVisibility: 'followers' }) },
|
||||
{ parameters: (): object => ({ followingVisibility: 'public' }) },
|
||||
{ parameters: (): object => ({ followersVisibility: 'private' }) },
|
||||
{ parameters: (): object => ({ followersVisibility: 'followers' }) },
|
||||
{ parameters: (): object => ({ followersVisibility: 'public' }) },
|
||||
{ parameters: (): object => ({ mutedWords: Array(19).fill(['xxxxx']) }) },
|
||||
{ parameters: (): object => ({ mutedWords: [['x'.repeat(194)]] }) },
|
||||
{ parameters: (): object => ({ mutedWords: [] }) },
|
||||
|
|
|
@ -19,6 +19,7 @@ import { CacheService } from '@/core/CacheService.js';
|
|||
import { IdService } from '@/core/IdService.js';
|
||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { sleep } from '../utils.js';
|
||||
import type { TestingModule } from '@nestjs/testing';
|
||||
import type { MockFunctionMetadata } from 'jest-mock';
|
||||
|
@ -32,6 +33,7 @@ describe('RoleService', () => {
|
|||
let rolesRepository: RolesRepository;
|
||||
let roleAssignmentsRepository: RoleAssignmentsRepository;
|
||||
let metaService: jest.Mocked<MetaService>;
|
||||
let notificationService: jest.Mocked<NotificationService>;
|
||||
let clock: lolex.InstalledClock;
|
||||
|
||||
function createUser(data: Partial<MiUser> = {}) {
|
||||
|
@ -71,6 +73,16 @@ describe('RoleService', () => {
|
|||
CacheService,
|
||||
IdService,
|
||||
GlobalEventService,
|
||||
{
|
||||
provide: NotificationService,
|
||||
useFactory: () => ({
|
||||
createNotification: jest.fn(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
provide: NotificationService.name,
|
||||
useExisting: NotificationService,
|
||||
},
|
||||
],
|
||||
})
|
||||
.useMocker((token) => {
|
||||
|
@ -93,6 +105,9 @@ describe('RoleService', () => {
|
|||
roleAssignmentsRepository = app.get<RoleAssignmentsRepository>(DI.roleAssignmentsRepository);
|
||||
|
||||
metaService = app.get<MetaService>(MetaService) as jest.Mocked<MetaService>;
|
||||
notificationService = app.get<NotificationService>(NotificationService) as jest.Mocked<NotificationService>;
|
||||
|
||||
await roleService.onModuleInit();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
@ -273,4 +288,57 @@ describe('RoleService', () => {
|
|||
expect(resultAfter25hAgain.canManageCustomEmojis).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('assign', () => {
|
||||
test('公開ロールの場合は通知される', async () => {
|
||||
const user = await createUser();
|
||||
const role = await createRole({
|
||||
isPublic: true,
|
||||
name: 'a',
|
||||
});
|
||||
|
||||
await roleService.assign(user.id, role.id);
|
||||
|
||||
clock.uninstall();
|
||||
await sleep(100);
|
||||
|
||||
const assignments = await roleAssignmentsRepository.find({
|
||||
where: {
|
||||
userId: user.id,
|
||||
roleId: role.id,
|
||||
},
|
||||
});
|
||||
expect(assignments).toHaveLength(1);
|
||||
|
||||
expect(notificationService.createNotification).toHaveBeenCalled();
|
||||
expect(notificationService.createNotification.mock.lastCall![0]).toBe(user.id);
|
||||
expect(notificationService.createNotification.mock.lastCall![1]).toBe('roleAssigned');
|
||||
expect(notificationService.createNotification.mock.lastCall![2]).toEqual({
|
||||
roleId: role.id,
|
||||
});
|
||||
});
|
||||
|
||||
test('非公開ロールの場合は通知されない', async () => {
|
||||
const user = await createUser();
|
||||
const role = await createRole({
|
||||
isPublic: false,
|
||||
name: 'a',
|
||||
});
|
||||
|
||||
await roleService.assign(user.id, role.id);
|
||||
|
||||
clock.uninstall();
|
||||
await sleep(100);
|
||||
|
||||
const assignments = await roleAssignmentsRepository.find({
|
||||
where: {
|
||||
userId: user.id,
|
||||
roleId: role.id,
|
||||
},
|
||||
});
|
||||
expect(assignments).toHaveLength(1);
|
||||
|
||||
expect(notificationService.createNotification).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue