Update OAuth inflection to match spec (#35160)
				
					
				
			This commit is contained in:
		@@ -23,5 +23,6 @@ RSpec/SpecFilePathFormat:
 | 
				
			|||||||
    ActivityPub: activitypub
 | 
					    ActivityPub: activitypub
 | 
				
			||||||
    DeepL: deepl
 | 
					    DeepL: deepl
 | 
				
			||||||
    FetchOEmbedService: fetch_oembed_service
 | 
					    FetchOEmbedService: fetch_oembed_service
 | 
				
			||||||
 | 
					    OAuth: oauth
 | 
				
			||||||
    OEmbedController: oembed_controller
 | 
					    OEmbedController: oembed_controller
 | 
				
			||||||
    OStatus: ostatus
 | 
					    OStatus: ostatus
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
 | 
					class OAuth::AuthorizationsController < Doorkeeper::AuthorizationsController
 | 
				
			||||||
  skip_before_action :authenticate_resource_owner!
 | 
					  skip_before_action :authenticate_resource_owner!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_action :store_current_location
 | 
					  before_action :store_current_location
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController
 | 
					class OAuth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController
 | 
				
			||||||
  skip_before_action :authenticate_resource_owner!
 | 
					  skip_before_action :authenticate_resource_owner!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_action :store_current_location
 | 
					  before_action :store_current_location
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Oauth::TokensController < Doorkeeper::TokensController
 | 
					class OAuth::TokensController < Doorkeeper::TokensController
 | 
				
			||||||
  def revoke
 | 
					  def revoke
 | 
				
			||||||
    unsubscribe_for_token if token.present? && authorized? && token.accessible?
 | 
					    unsubscribe_for_token if token.present? && authorized? && token.accessible?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,11 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Oauth::UserinfoController < Api::BaseController
 | 
					class OAuth::UserinfoController < Api::BaseController
 | 
				
			||||||
  before_action -> { doorkeeper_authorize! :profile }, only: [:show]
 | 
					  before_action -> { doorkeeper_authorize! :profile }, only: [:show]
 | 
				
			||||||
  before_action :require_user!
 | 
					  before_action :require_user!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def show
 | 
					  def show
 | 
				
			||||||
    @account = current_account
 | 
					    @account = current_account
 | 
				
			||||||
    render json: @account, serializer: OauthUserinfoSerializer
 | 
					    render json: @account, serializer: OAuthUserinfoSerializer
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module WellKnown
 | 
					module WellKnown
 | 
				
			||||||
  class OauthMetadataController < ActionController::Base # rubocop:disable Rails/ApplicationController
 | 
					  class OAuthMetadataController < ActionController::Base # rubocop:disable Rails/ApplicationController
 | 
				
			||||||
    include CacheConcern
 | 
					    include CacheConcern
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Prevent `active_model_serializer`'s `ActionController::Serialization` from calling `current_user`
 | 
					    # Prevent `active_model_serializer`'s `ActionController::Serialization` from calling `current_user`
 | 
				
			||||||
@@ -13,8 +13,8 @@ module WellKnown
 | 
				
			|||||||
      # new OAuth scopes are added), we don't use expires_in to cache upstream,
 | 
					      # new OAuth scopes are added), we don't use expires_in to cache upstream,
 | 
				
			||||||
      # instead just caching in the rails cache:
 | 
					      # instead just caching in the rails cache:
 | 
				
			||||||
      render_with_cache(
 | 
					      render_with_cache(
 | 
				
			||||||
        json: ::OauthMetadataPresenter.new,
 | 
					        json: ::OAuthMetadataPresenter.new,
 | 
				
			||||||
        serializer: ::OauthMetadataSerializer,
 | 
					        serializer: ::OAuthMetadataSerializer,
 | 
				
			||||||
        content_type: 'application/json',
 | 
					        content_type: 'application/json',
 | 
				
			||||||
        expires_in: 15.minutes
 | 
					        expires_in: 15.minutes
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class OauthMetadataPresenter < ActiveModelSerializers::Model
 | 
					class OAuthMetadataPresenter < ActiveModelSerializers::Model
 | 
				
			||||||
  include RoutingHelper
 | 
					  include RoutingHelper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  attributes :issuer, :authorization_endpoint, :token_endpoint,
 | 
					  attributes :issuer, :authorization_endpoint, :token_endpoint,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class OauthMetadataSerializer < ActiveModel::Serializer
 | 
					class OAuthMetadataSerializer < ActiveModel::Serializer
 | 
				
			||||||
  attributes :issuer, :authorization_endpoint, :token_endpoint,
 | 
					  attributes :issuer, :authorization_endpoint, :token_endpoint,
 | 
				
			||||||
             :revocation_endpoint, :userinfo_endpoint, :scopes_supported,
 | 
					             :revocation_endpoint, :userinfo_endpoint, :scopes_supported,
 | 
				
			||||||
             :response_types_supported, :response_modes_supported,
 | 
					             :response_types_supported, :response_modes_supported,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class OauthUserinfoSerializer < ActiveModel::Serializer
 | 
					class OAuthUserinfoSerializer < ActiveModel::Serializer
 | 
				
			||||||
  include RoutingHelper
 | 
					  include RoutingHelper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  attributes :iss, :sub, :name, :preferred_username, :profile, :picture
 | 
					  attributes :iss, :sub, :name, :preferred_username, :profile, :picture
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
 | 
				
			|||||||
  inflect.acronym 'DeepL'
 | 
					  inflect.acronym 'DeepL'
 | 
				
			||||||
  inflect.acronym 'DSL'
 | 
					  inflect.acronym 'DSL'
 | 
				
			||||||
  inflect.acronym 'JsonLd'
 | 
					  inflect.acronym 'JsonLd'
 | 
				
			||||||
 | 
					  inflect.acronym 'OAuth'
 | 
				
			||||||
  inflect.acronym 'OEmbed'
 | 
					  inflect.acronym 'OEmbed'
 | 
				
			||||||
  inflect.acronym 'OStatus'
 | 
					  inflect.acronym 'OStatus'
 | 
				
			||||||
  inflect.acronym 'PubSubHubbub'
 | 
					  inflect.acronym 'PubSubHubbub'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AddSuperappToOauthApplications < ActiveRecord::Migration[5.0]
 | 
					class AddSuperappToOAuthApplications < ActiveRecord::Migration[5.0]
 | 
				
			||||||
  def change
 | 
					  def change
 | 
				
			||||||
    add_column :oauth_applications, :superapp, :boolean, default: false, null: false
 | 
					    add_column :oauth_applications, :superapp, :boolean, default: false, null: false
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AddWebsiteToOauthApplication < ActiveRecord::Migration[5.0]
 | 
					class AddWebsiteToOAuthApplication < ActiveRecord::Migration[5.0]
 | 
				
			||||||
  def change
 | 
					  def change
 | 
				
			||||||
    add_column :oauth_applications, :website, :string
 | 
					    add_column :oauth_applications, :website, :string
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AddLastUsedAtToOauthAccessTokens < ActiveRecord::Migration[6.1]
 | 
					class AddLastUsedAtToOAuthAccessTokens < ActiveRecord::Migration[6.1]
 | 
				
			||||||
  def change
 | 
					  def change
 | 
				
			||||||
    safety_assured do
 | 
					    safety_assured do
 | 
				
			||||||
      change_table(:oauth_access_tokens, bulk: true) do |t|
 | 
					      change_table(:oauth_access_tokens, bulk: true) do |t|
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 | 
					require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class OptimizeNullIndexOauthAccessTokensRefreshToken < ActiveRecord::Migration[5.2]
 | 
					class OptimizeNullIndexOAuthAccessTokensRefreshToken < ActiveRecord::Migration[5.2]
 | 
				
			||||||
  include Mastodon::MigrationHelpers
 | 
					  include Mastodon::MigrationHelpers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  disable_ddl_transaction!
 | 
					  disable_ddl_transaction!
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 | 
					require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class OptimizeNullIndexOauthAccessTokensResourceOwnerId < ActiveRecord::Migration[5.2]
 | 
					class OptimizeNullIndexOAuthAccessTokensResourceOwnerId < ActiveRecord::Migration[5.2]
 | 
				
			||||||
  include Mastodon::MigrationHelpers
 | 
					  include Mastodon::MigrationHelpers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  disable_ddl_transaction!
 | 
					  disable_ddl_transaction!
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require 'rails_helper'
 | 
					require 'rails_helper'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RSpec.describe Oauth::AuthorizationsController do
 | 
					RSpec.describe OAuth::AuthorizationsController do
 | 
				
			||||||
  let(:app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: 'http://localhost/', scopes: 'read') }
 | 
					  let(:app) { Doorkeeper::Application.create!(name: 'test', redirect_uri: 'http://localhost/', scopes: 'read') }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe 'GET #new' do
 | 
					  describe 'GET #new' do
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require 'rails_helper'
 | 
					require 'rails_helper'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RSpec.describe Oauth::AuthorizedApplicationsController do
 | 
					RSpec.describe OAuth::AuthorizedApplicationsController do
 | 
				
			||||||
  render_views
 | 
					  render_views
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe 'GET #index' do
 | 
					  describe 'GET #index' do
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require 'rails_helper'
 | 
					require 'rails_helper'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RSpec.describe 'Oauth Userinfo Endpoint' do
 | 
					RSpec.describe 'OAuth Userinfo Endpoint' do
 | 
				
			||||||
  include RoutingHelper
 | 
					  include RoutingHelper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let(:user)     { Fabricate(:user) }
 | 
					  let(:user)     { Fabricate(:user) }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user