From 2eaf1ddf88bfac7c9debfe3a19b871bced6ca868 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Wed, 14 Jun 2023 22:08:39 +1000 Subject: [PATCH] Clean up specs --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/action.rb | 6 +++--- spec/requests/create_post_spec.rb | 9 ++------- spec/slices/admin/action_spec.rb | 5 ----- spec/spec_helper.rb | 5 +++++ 6 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 spec/slices/admin/action_spec.rb diff --git a/Gemfile b/Gemfile index 8ad82db..b066119 100644 --- a/Gemfile +++ b/Gemfile @@ -51,6 +51,8 @@ gem "image_processing", "~> 1.0" gem "sentry-ruby" +gem "warning" + group :cli, :development do gem "hanami-reloader" end diff --git a/Gemfile.lock b/Gemfile.lock index 91b9075..a8821e7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/action.rb b/app/action.rb index 502a579..15b2636 100644 --- a/app/action.rb +++ b/app/action.rb @@ -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? diff --git a/spec/requests/create_post_spec.rb b/spec/requests/create_post_spec.rb index 5c7d6a7..fe93b0e 100644 --- a/spec/requests/create_post_spec.rb +++ b/spec/requests/create_post_spec.rb @@ -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 diff --git a/spec/slices/admin/action_spec.rb b/spec/slices/admin/action_spec.rb deleted file mode 100644 index e42b252..0000000 --- a/spec/slices/admin/action_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe Admin::Action do - xit "works" -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 72aef30..b192c67 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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 \ No newline at end of file