Skip to content

Commit 2a2cdd3

Browse files
jdxchenrui333
andcommitted
fnox 1.5.2 (new formula)
- Added Formula/f/fnox.rb - Improve fnox formula test with real age encryption - Generate test age key using system age-keygen instead of hardcoded key - Use fnox set to properly encrypt test secret before testing - Add test for fnox get TEST_SECRET to verify decryption works - Fix environment variable to use FNOX_AGE_KEY instead of AGE_KEY - Provides better end-to-end validation of fnox installation Co-Authored-By: jdx <[email protected]> Co-Authored-By: Rui Chen <[email protected]>
1 parent f4b2411 commit 2a2cdd3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Formula/f/fnox.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
class Fnox < Formula
2+
desc "Fort Knox for your secrets - flexible secret management tool"
3+
homepage "https://fnox.jdx.dev/"
4+
url "https://github.com/jdx/fnox/archive/refs/tags/v1.5.2.tar.gz"
5+
sha256 "93e47266a278ebdb203e3cbd96cda775923b1c1ee15cb6791a67e2dba7ab54ff"
6+
license "MIT"
7+
head "https://github.com/jdx/fnox.git", branch: "main"
8+
9+
depends_on "pkgconf" => :build
10+
depends_on "rust" => :build
11+
depends_on "age" => :test
12+
depends_on "usage"
13+
14+
on_linux do
15+
depends_on "openssl@3"
16+
end
17+
18+
def install
19+
# Ensure that the `openssl` crate picks up the intended library.
20+
ENV["OPENSSL_DIR"] = Formula["openssl@3"].opt_prefix
21+
ENV["OPENSSL_NO_VENDOR"] = "1"
22+
23+
system "cargo", "install", *std_cargo_args
24+
25+
generate_completions_from_executable(bin/"fnox", "completion")
26+
end
27+
28+
test do
29+
assert_match version.to_s, shell_output("#{bin}/fnox --version")
30+
31+
test_key = shell_output("age-keygen")
32+
test_key_line = test_key.lines.grep(/^# public key:/).first.sub(/^# public key: /, "").strip
33+
secret_key_line = test_key.lines.grep(/^AGE-SECRET-KEY-/).first.strip
34+
35+
(testpath/"fnox.toml").write <<~TOML
36+
[providers]
37+
age = { type = "age", recipients = ["#{test_key_line}"] }
38+
TOML
39+
40+
ENV["FNOX_AGE_KEY"] = secret_key_line
41+
system bin/"fnox", "set", "TEST_SECRET", "test-secret-value", "--provider", "age"
42+
assert_match "TEST_SECRET", shell_output("#{bin}/fnox list")
43+
assert_match "test-secret-value", shell_output("#{bin}/fnox get TEST_SECRET")
44+
end
45+
end

0 commit comments

Comments
 (0)