Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rspec_api_文档中的基本身份验证_Ruby On Rails_Ruby_Rspec - Fatal编程技术网

Ruby on rails rspec_api_文档中的基本身份验证

Ruby on rails rspec_api_文档中的基本身份验证,ruby-on-rails,ruby,rspec,Ruby On Rails,Ruby,Rspec,我过去常有大摇大摆的医生。我有一个POST端点,唯一的任务是接收webhook数据并发送响应。问题是我已经有了基本的身份验证,包括名称和密码: webhook\u controller.rb class Api::V1::WebhooksController < ActionController::API include ActionController::HttpAuthentication::Basic::ControllerMethods include ActionCont

我过去常有大摇大摆的医生。我有一个POST端点,唯一的任务是接收webhook数据并发送响应。问题是我已经有了基本的身份验证,包括
名称
密码

webhook\u controller.rb

class Api::V1::WebhooksController < ActionController::API
  include ActionController::HttpAuthentication::Basic::ControllerMethods
  include ActionController::HttpAuthentication::Token::ControllerMethods

  http_basic_authenticate_with name: Rails.application.credentials.webhook_auth_name,
                               password: Rails.application.credentials.webhook_auth_password

  def create
    return head(:not_implemented) unless Flipflop.digital_human_integration?
 # ...
 # some other code
  end
但我得到的是401而不是501

require 'rails_helper'
require 'rspec_api_documentation/dsl'

resource 'Webhooks' do
  explanation 'Dialogflow webhooks receiver endpoint'

  authentication :basic, name: Rails.application.credentials.webhook_auth_name, password: Rails.application.credentials.webhook_auth_password

  post '/api/v1/webhooks' do
    context 'with feature flag set to false' do
      before do
        Flipflop::FeatureSet.current.test!.switch!(:digital_human_integration, false)
      end

      example_request 'returns 501' do
        expect(response_status).to eq http_status_code(:not_implemented)
      end
    end