Files
ubicloud/spec/routes/runtime/auth_spec.rb
Burak Velioglu 18b24f2a2c Return error json without error key for runtime endpoints
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.
2024-12-24 15:35:13 +03:00

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