mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 18:24:58 +00:00
Add API for App Index
- Add tests for unauthorised response for APIs which require authentication
This commit is contained in:
26
spec/controllers/apps_controller_spec.rb
Normal file
26
spec/controllers/apps_controller_spec.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AppsController, type: :controller do
|
||||
context "With Authentication" do
|
||||
let(:device){create(:device)}
|
||||
before(:each) do
|
||||
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(device.access_token)
|
||||
end
|
||||
it "#index" do
|
||||
expect(App).to receive(:all)
|
||||
|
||||
get :index, format: :json
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
context "Without Authentication" do
|
||||
it "#index" do
|
||||
get :index, format: :json
|
||||
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user