From fd66df599743e9d11a4d3f8d198ec3533ba26767 Mon Sep 17 00:00:00 2001 From: RogerBW Date: Mon, 22 Nov 2021 17:49:08 +0000 Subject: [PATCH] FEATURE: adds uploads scope for API keys (#14941) * FEATURE: adds uploads scope for API keys * Add basic test, change "image" to "file" --- app/models/api_key_scope.rb | 3 +++ config/locales/client.en.yml | 2 ++ spec/requests/admin/api_controller_spec.rb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rb index 9016da3b68e..08cf32a9dd0 100644 --- a/app/models/api_key_scope.rb +++ b/app/models/api_key_scope.rb @@ -35,6 +35,9 @@ class ApiKeyScope < ActiveRecord::Base posts: { edit: { actions: %w[posts#update], params: %i[id] } }, + uploads: { + create: { actions: %w[uploads#create] } + }, users: { bookmarks: { actions: %w[users#bookmarks], params: %i[username] }, sync_sso: { actions: %w[admin/users#sync_sso], params: %i[sso sig] }, diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 65dd71c2dc9..431c046b23c 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4193,6 +4193,8 @@ en: wordpress: Necessary for the WordPress wp-discourse plugin to work. posts: edit: Edit any post or a specific one. + uploads: + create: Upload a new file. users: bookmarks: List user bookmarks. It returns bookmark reminders when using the ICS format. sync_sso: Synchronize a user using DiscourseConnect. diff --git a/spec/requests/admin/api_controller_spec.rb b/spec/requests/admin/api_controller_spec.rb index e1f2d4d4e2b..2be52a0a974 100644 --- a/spec/requests/admin/api_controller_spec.rb +++ b/spec/requests/admin/api_controller_spec.rb @@ -237,7 +237,7 @@ describe Admin::ApiController do scopes = response.parsed_body['scopes'] - expect(scopes.keys).to contain_exactly('topics', 'users', 'email', 'posts', 'global') + expect(scopes.keys).to contain_exactly('topics', 'users', 'email', 'posts', 'uploads', 'global') end end end