From 29656b5e9720c4b0cec6cfb763f66b731a04e320 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 15 Sep 2020 10:21:40 -0500 Subject: [PATCH] Fixing tests. --- api_tests/src/comment.spec.ts | 4 +- api_tests/src/community.spec.ts | 2 +- api_tests/src/follow.spec.ts | 1 + api_tests/src/shared.ts | 12 +++--- api_tests/src/user.spec.ts | 2 +- docker/federation/docker-compose.yml | 20 ++++++--- docker/federation/nginx.conf | 62 ++++++++++++++-------------- src/apub/community.rs | 12 ++++++ 8 files changed, 69 insertions(+), 46 deletions(-) diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index 83526cf96..0f8f59d62 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -235,7 +235,7 @@ test('Reply to a comment', async () => { test('Mention beta', async () => { // Create a mention on alpha - let mentionContent = 'A test mention of @lemmy_beta@lemmy-beta:8550'; + let mentionContent = 'A test mention of @lemmy_beta@lemmy-beta:8551'; let commentRes = await createComment(alpha, postRes.post.id); await delay(); let mentionRes = await createComment( @@ -275,7 +275,7 @@ test('A and G subscribe to B (center) A posts, G mentions B, it gets announced t let gammaPost = search.posts[0]; let commentContent = - 'A jest test federated comment announce, lets mention @lemmy_beta@lemmy-beta:8550'; + 'A jest test federated comment announce, lets mention @lemmy_beta@lemmy-beta:8551'; let commentRes = await createComment( gamma, gammaPost.id, diff --git a/api_tests/src/community.spec.ts b/api_tests/src/community.spec.ts index 0a28369d1..f1cbf8db7 100644 --- a/api_tests/src/community.spec.ts +++ b/api_tests/src/community.spec.ts @@ -26,7 +26,7 @@ test('Create community', async () => { await delay(); // Cache the community on beta, make sure it has the other fields - let searchShort = `!${prevName}@lemmy-alpha:8540`; + let searchShort = `!${prevName}@lemmy-alpha:8541`; let search = await searchForCommunity(beta, searchShort); let communityOnBeta = search.communities[0]; expect(communityOnBeta.name).toBe(communityRes.community.name); diff --git a/api_tests/src/follow.spec.ts b/api_tests/src/follow.spec.ts index 41af6effb..e238dc636 100644 --- a/api_tests/src/follow.spec.ts +++ b/api_tests/src/follow.spec.ts @@ -1,3 +1,4 @@ +jest.setTimeout(120000); import { alpha, setupLogins, diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index 1199e8d60..6444b8122 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -50,23 +50,23 @@ export interface API { } export let alpha: API = { - client: new LemmyHttp('http://localhost:8540/api/v1'), + client: new LemmyHttp('http://localhost:8541/api/v1'), }; export let beta: API = { - client: new LemmyHttp('http://localhost:8550/api/v1'), + client: new LemmyHttp('http://localhost:8551/api/v1'), }; export let gamma: API = { - client: new LemmyHttp('http://localhost:8560/api/v1'), + client: new LemmyHttp('http://localhost:8561/api/v1'), }; export let delta: API = { - client: new LemmyHttp('http://localhost:8570/api/v1'), + client: new LemmyHttp('http://localhost:8571/api/v1'), }; export let epsilon: API = { - client: new LemmyHttp('http://localhost:8580/api/v1'), + client: new LemmyHttp('http://localhost:8581/api/v1'), }; export async function setupLogins() { @@ -236,7 +236,7 @@ export async function searchForBetaCommunity( // Make sure lemmy-beta/c/main is cached on lemmy_alpha // Use short-hand search url let form: SearchForm = { - q: '!main@lemmy-beta:8550', + q: '!main@lemmy-beta:8551', type_: SearchType.Communities, sort: SortType.TopAll, }; diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index b685e2965..8a0c2a281 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -18,7 +18,7 @@ test('Create user', async () => { let site = await getSite(alpha, auth); expect(site.my_user).toBeDefined(); - apShortname = `@${site.my_user.name}@lemmy-alpha:8540`; + apShortname = `@${site.my_user.name}@lemmy-alpha:8541`; }); test('Save user settings, check changed bio from beta', async () => { diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 449f0c664..d18d000fe 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -15,11 +15,11 @@ services: depends_on: - pictrs - iframely - - lemmy-alpha-ui - - lemmy-beta-ui - - lemmy-gamma-ui - - lemmy-delta-ui - - lemmy-epsilon-ui + - lemmy-alpha + - lemmy-beta + - lemmy-gamma + - lemmy-delta + - lemmy-epsilon pictrs: restart: always @@ -56,6 +56,8 @@ services: - RUST_LOG=debug depends_on: - postgres_alpha + ports: + - "8541:8541" postgres_alpha: image: postgres:12-alpine environment: @@ -93,6 +95,8 @@ services: - RUST_LOG=debug depends_on: - postgres_beta + ports: + - "8551:8551" postgres_beta: image: postgres:12-alpine environment: @@ -130,6 +134,8 @@ services: - RUST_LOG=debug depends_on: - postgres_gamma + ports: + - "8561:8561" postgres_gamma: image: postgres:12-alpine environment: @@ -168,6 +174,8 @@ services: - RUST_LOG=debug depends_on: - postgres_delta + ports: + - "8571:8571" postgres_delta: image: postgres:12-alpine environment: @@ -206,6 +214,8 @@ services: - RUST_LOG=debug depends_on: - postgres_epsilon + ports: + - "8581:8581" postgres_epsilon: image: postgres:12-alpine environment: diff --git a/docker/federation/nginx.conf b/docker/federation/nginx.conf index ed008c844..f787a9d2f 100644 --- a/docker/federation/nginx.conf +++ b/docker/federation/nginx.conf @@ -11,8 +11,14 @@ http { # Upload limit for pictshare client_max_body_size 50M; + location /api/v1 { + proxy_pass http://lemmy-alpha:8541/api/v1; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } location / { - proxy_pass http://lemmy-alpha-ui:1234/; + proxy_pass http://lemmy-alpha-ui:1234; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -20,12 +26,6 @@ http { # Cuts off the trailing slash on URLs to make them valid rewrite ^(.+)/+$ $1 permanent; } - location /api/v1/ws { - proxy_pass http://lemmy-alpha:8541; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } location /iframely/ { proxy_pass http://iframely:80/; proxy_set_header X-Real-IP $remote_addr; @@ -42,6 +42,12 @@ http { # Upload limit for pictshare client_max_body_size 50M; + location /api/v1 { + proxy_pass http://lemmy-beta:8551/api/v1; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } location / { proxy_pass http://lemmy-beta-ui:1234; proxy_set_header X-Real-IP $remote_addr; @@ -51,12 +57,6 @@ http { # Cuts off the trailing slash on URLs to make them valid rewrite ^(.+)/+$ $1 permanent; } - location /api/v1/ws { - proxy_pass http://lemmy-beta:8551; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } location /iframely/ { proxy_pass http://iframely:80/; proxy_set_header X-Real-IP $remote_addr; @@ -73,6 +73,12 @@ http { # Upload limit for pictshare client_max_body_size 50M; + location /api/v1 { + proxy_pass http://lemmy-gamma:8561/api/v1; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } location / { proxy_pass http://lemmy-gamma-ui:1234; proxy_set_header X-Real-IP $remote_addr; @@ -82,12 +88,6 @@ http { # Cuts off the trailing slash on URLs to make them valid rewrite ^(.+)/+$ $1 permanent; } - location /api/v1/ws { - proxy_pass http://lemmy-gamma:8561; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } location /iframely/ { proxy_pass http://iframely:80/; proxy_set_header X-Real-IP $remote_addr; @@ -104,6 +104,12 @@ http { # Upload limit for pictshare client_max_body_size 50M; + location /api/v1 { + proxy_pass http://lemmy-delta:8571/api/v1; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } location / { proxy_pass http://lemmy-delta-ui:1234; proxy_set_header X-Real-IP $remote_addr; @@ -113,12 +119,6 @@ http { # Cuts off the trailing slash on URLs to make them valid rewrite ^(.+)/+$ $1 permanent; } - location /api/v1/ws { - proxy_pass http://lemmy-delta:8571; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } location /iframely/ { proxy_pass http://iframely:80/; proxy_set_header X-Real-IP $remote_addr; @@ -135,6 +135,12 @@ http { # Upload limit for pictshare client_max_body_size 50M; + location /api/v1 { + proxy_pass http://lemmy-epsilon:8581/api/v1; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } location / { proxy_pass http://lemmy-epsilon-ui:1234; proxy_set_header X-Real-IP $remote_addr; @@ -144,12 +150,6 @@ http { # Cuts off the trailing slash on URLs to make them valid rewrite ^(.+)/+$ $1 permanent; } - location /api/v1/ws { - proxy_pass http://lemmy-epsilon:8581; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } location /iframely/ { proxy_pass http://iframely:80/; proxy_set_header X-Real-IP $remote_addr; diff --git a/src/apub/community.rs b/src/apub/community.rs index 89819f453..8f64c671d 100644 --- a/src/apub/community.rs +++ b/src/apub/community.rs @@ -94,6 +94,18 @@ impl ToApub for Community { group.set_content(d); } + if let Some(icon) = &self.icon { + let mut image = Image::new(); + image.set_url(icon.to_owned()); + group.set_icon(image.into_any_base()?); + } + + if let Some(banner_url) = &self.banner { + let mut image = Image::new(); + image.set_url(banner_url.to_owned()); + group.set_image(image.into_any_base()?); + } + let mut ap_actor = ApActor::new(self.get_inbox_url()?, group); ap_actor .set_preferred_username(self.title.to_owned())