Ruby on rails rspec_api_文档中的基本身份验证
我过去常有大摇大摆的医生。我有一个POST端点,唯一的任务是接收webhook数据并发送响应。问题是我已经有了基本的身份验证,包括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
名称
和密码
:
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