mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 10:14:59 +00:00
Add API for App Index
- Add tests for unauthorised response for APIs which require authentication
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe HeartbeatsController, type: :controller do
|
||||
let(:heartbeat) {FactoryGirl.create(:heartbeat)}
|
||||
|
||||
before(:each) do
|
||||
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(heartbeat.device.access_token)
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "POST #create" do
|
||||
let(:heartbeat) {FactoryGirl.create(:heartbeat)}
|
||||
|
||||
before(:each) do
|
||||
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(heartbeat.device.access_token)
|
||||
end
|
||||
|
||||
it "Respond with next heartbeat time" do
|
||||
post :create, format: :json
|
||||
expect(response).to have_http_status(:created)
|
||||
@@ -15,5 +16,12 @@ RSpec.describe HeartbeatsController, type: :controller do
|
||||
end
|
||||
end
|
||||
|
||||
context "Require Authentication" do
|
||||
it "#create" do
|
||||
post :create, format: :json
|
||||
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user