Returning an error json without an error key on top for runtime endpoints. It is required because docker layer caching expects error in this format to skip duplicate cache entries. Passing it in this way works properly with the cache proxy as we directly pass the error to the client without parsing it.
34 lines
867 B
Ruby
34 lines
867 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "spec_helper"
|
|
|
|
RSpec.describe Clover, "auth" do
|
|
it "no jwt token" do
|
|
get "/runtime"
|
|
|
|
expect(last_response).to have_runtime_error(400, "invalid JWT format or claim in Authorization header")
|
|
end
|
|
|
|
it "wrong jwt token" do
|
|
header "Authorization", "Bearer wrongjwt"
|
|
get "/runtime"
|
|
|
|
expect(last_response).to have_runtime_error(400, "invalid JWT format or claim in Authorization header")
|
|
end
|
|
|
|
it "valid jwt token but no active vm" do
|
|
vm = Vm.new_with_id
|
|
header "Authorization", "Bearer #{vm.runtime_token}"
|
|
get "/runtime"
|
|
|
|
expect(last_response).to have_runtime_error(400, "invalid JWT format or claim in Authorization header")
|
|
end
|
|
|
|
it "valid jwt token with an active vm" do
|
|
login_runtime(create_vm)
|
|
get "/runtime"
|
|
|
|
expect(last_response.status).to eq(404)
|
|
end
|
|
end
|