Skip to content

Commit 6a206b0

Browse files
committed
Add SetUserToAuthenticatedUser request mutator
1 parent 5131356 commit 6a206b0

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.0.6] - 2025-05-01
2+
3+
- Add SetUserToAuthenticatedUser request mutator
4+
15
## [0.0.5] - 2025-05-01
26

37
- Add an ApiKeyAuthenticator

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-auth-http (0.0.5)
4+
foobara-auth-http (0.0.6)
55
foobara (~> 0.0.108)
66
foobara-auth (~> 0.0.1)
77
foobara-http-command-connector (~> 0.0.1)
@@ -82,7 +82,7 @@ GEM
8282
foobara-files-generator
8383
foobara-files-generator (0.0.5)
8484
foobara
85-
foobara-http-command-connector (0.0.24)
85+
foobara-http-command-connector (0.0.25)
8686
foobara (~> 0.0.88)
8787
foobara-local-files-crud-driver-generator (0.0.3)
8888
foobara
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
RSpec.describe Foobara::AuthHttp::SetUserToAuthenticatedUser do
2+
let(:command) do
3+
instance_double(Foobara::TransformedCommand, authenticated_user:)
4+
end
5+
let(:authenticated_user) { Object.new }
6+
let(:request) do
7+
Foobara::CommandConnectors::Http::Request.new(
8+
path: "/whatever"
9+
).tap { |r| r.command = command }
10+
end
11+
12+
let(:mutator) { described_class.new }
13+
14+
it "fills in the refresh_token input from the cookie" do
15+
expect {
16+
mutator.mutate(request)
17+
}.to change(request, :inputs).from({}).to(user: authenticated_user)
18+
end
19+
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Foobara
2+
module AuthHttp
3+
class SetUserToAuthenticatedUser < Foobara::CommandConnectors::Http::SetInputToProcResult
4+
# TODO: move this into base class as default?
5+
class << self
6+
def requires_declaration_data?
7+
false
8+
end
9+
end
10+
11+
def initialize
12+
self.attribute_name = :user
13+
self.input_value_proc = proc { command.authenticated_user }
14+
15+
super
16+
end
17+
end
18+
end
19+
end

version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Foobara
22
module AuthHttp
3-
VERSION = "0.0.5".freeze
3+
VERSION = "0.0.6".freeze
44

55
local_ruby_version = File.read("#{__dir__}/.ruby-version").chomp
66
local_ruby_version_minor = local_ruby_version[/\A(\d+\.\d+)\.\d+\z/, 1]

0 commit comments

Comments
 (0)