jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / b / blackbox.rb
blob886b3594e4cf55c8c5280bc33f1fb1917b3ad00c
1 class Blackbox < Formula
2   desc "Safely store secrets in Git/Mercurial/Subversion"
3   homepage "https://github.com/StackExchange/blackbox"
4   url "https://github.com/StackExchange/blackbox/archive/refs/tags/v1.20220610.tar.gz"
5   sha256 "f1efcca6680159f244eb44fdb78e92b521760b875fa5a36e4c433b93ed0f87c1"
6   license "MIT"
7   version_scheme 1
9   livecheck do
10     url :stable
11     regex(/^v?(\d+(?:\.\d+)*\.\d{6,8}(?:\.\d+)*)$/i)
12   end
14   bottle do
15     rebuild 1
16     sha256 cellar: :any_skip_relocation, all: "55abf9c858ccaf04d8ab764718fa5810f09adb66c150ae3a9f263622a1cae753"
17   end
19   depends_on "gnupg"
21   def install
22     libexec.install Dir["bin/*"]
23     bin.write_exec_script Dir[libexec/"*"].select { |f| File.executable? f }
24   end
26   test do
27     (testpath/"batch.gpg").write <<~EOS
28       Key-Type: RSA
29       Key-Length: 2048
30       Subkey-Type: RSA
31       Subkey-Length: 2048
32       Name-Real: Testing
33       Name-Email: testing@foo.bar
34       Expire-Date: 1d
35       %no-protection
36       %commit
37     EOS
38     begin
39       system Formula["gnupg"].opt_bin/"gpg", "--batch", "--gen-key", "batch.gpg"
40       system "git", "init"
41       system bin/"blackbox_initialize", "yes"
42       add_created_key = shell_output("#{bin}/blackbox_addadmin Testing 2>&1")
43       assert_match "<testing@foo.bar>", add_created_key
44     ensure
45       system Formula["gnupg"].opt_bin/"gpgconf", "--kill", "gpg-agent"
46       system Formula["gnupg"].opt_bin/"gpgconf", "--homedir", "keyrings/live",
47                                                  "--kill", "gpg-agent"
48     end
49   end
50 end