Skip to content

Commit 9eee9a8

Browse files
author
emmanuel.john
committed
granted: fix missing assume binary
Granted requires both 'granted' and 'assume' binaries to function. The assume script exports AWS credentials to the parent shell. Closes #249904
1 parent 700340d commit 9eee9a8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Formula/g/granted.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,32 @@ class Granted < Formula
2020
def install
2121
ldflags = "-s -w -X github.com/common-fate/granted/internal/build.Version=#{version}"
2222
system "go", "build", *std_go_args(ldflags:), "./cmd/granted"
23+
bin.install_symlink "granted" => "assumego"
24+
# these must be in bin, and not sourced automatically
25+
bin.install "scripts/assume"
26+
bin.install "scripts/assume.fish"
2327
end
2428

2529
test do
2630
assert_match version.to_s, shell_output("#{bin}/granted --version")
2731

2832
output = shell_output("#{bin}/granted auth configure 2>&1", 1)
2933
assert_match "[✘] please provide a url argument", output
34+
35+
ENV["GRANTED_ALIAS_CONFIGURED"] = "true"
36+
assert_match version.to_s, shell_output("#{bin}/assume --version")
37+
assert_match version.to_s, shell_output("#{bin}/assumego --version")
38+
39+
# pre-create config to avoid interactive browser prompt
40+
# .granted on Linux, .dgranted on macOS
41+
%w[.granted .dgranted].each do |dir|
42+
(testpath/dir).mkpath
43+
(testpath/dir/"config").write <<~EOS
44+
DefaultBrowser = "CHROME"
45+
EOS
46+
end
47+
# pipe_output provides empty stdin to avoid interactive profile selection
48+
output = pipe_output("#{bin}/assume non-existing-role 2>&1", "")
49+
assert_match "does not match any profiles", output
3050
end
3151
end

0 commit comments

Comments
 (0)