Clean up specs

This commit is contained in:
2023-06-14 22:08:39 +10:00
parent 7c1a638b58
commit 2eaf1ddf88
6 changed files with 14 additions and 15 deletions

View File

@@ -51,6 +51,8 @@ gem "image_processing", "~> 1.0"
gem "sentry-ruby"
gem "warning"
group :cli, :development do
gem "hanami-reloader"
end

View File

@@ -443,6 +443,7 @@ GEM
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
warning (1.3.0)
webmention (7.0.0)
http (~> 5.0)
indieweb-endpoints (~> 8.0)
@@ -508,6 +509,7 @@ DEPENDENCIES
standardrb
time_math2
timecop
warning
webmention
RUBY VERSION

View File

@@ -6,7 +6,7 @@ require "httparty"
require "dry-monads"
require "dry-matcher"
require "dry/matcher/result_matcher"
require "pry"
module Adamantium
class Action < Hanami::Action
include Deps["logger",
@@ -22,6 +22,8 @@ module Adamantium
handle_exception StandardError => :handle_error
def authenticate!(req, res)
halt 400 if req.env["HTTP_AUTHORIZATION"] && req.params[:access_token]
if Hanami.env == :development || Hanami.env == :test
req.env[:scopes] = verify_token(nil)
return true
@@ -29,8 +31,6 @@ module Adamantium
# Pull out and verify the authorization header or access_token
halt 400 if req.env["HTTP_AUTHORIZATION"] && req.params["access_token"]
if req.env["HTTP_AUTHORIZATION"]
header = req.env["HTTP_AUTHORIZATION"].match(/Bearer (.*)$/)
access_token = header[1] unless header.nil?

View File

@@ -159,17 +159,12 @@ RSpec.describe "Post creation", :db, :requests do
end
context "auth" do
xit "does not allow multiple auth methods" do
it "does not allow multiple auth methods" do
params = {
access_token: "foo"
}
headers = {
HTTP_AUTHORIZATION: "Bearer foo",
CONTENT_TYPE: "application/json"
}
post "/micropub", params.to_json, headers
post "/micropub", params, "HTTP_AUTHORIZATION" => "Bearer foo"
expect(last_response.status).to eq 400
end

View File

@@ -1,5 +0,0 @@
# frozen_string_literal: true
RSpec.describe Admin::Action do
xit "works"
end

View File

@@ -1,6 +1,7 @@
# frozen_string_literal: true
require "pathname"
require "warning"
SPEC_ROOT = Pathname(__dir__).realpath.freeze
ENV["HANAMI_ENV"] ||= "test"
@@ -10,3 +11,7 @@ require "timecop"
require_relative "support/rspec"
require_relative "support/feature_loader"
Gem.path.each do |path|
Warning.ignore(//, path)
end