class PassOtp < Formula desc "Pass extension for managing one-time-password tokens" homepage "https://github.com/tadfisher/pass-otp" url "https://github.com/tadfisher/pass-otp/releases/download/v1.2.0/pass-otp-1.2.0.tar.gz" sha256 "5720a649267a240a4f7ba5a6445193481070049c1d08ba38b00d20fc551c3a67" license "GPL-3.0-or-later" no_autobump! because: :requires_manual_review bottle do rebuild 3 sha256 cellar: :any_skip_relocation, all: "e79fd90d07ba181d43a57123d3dfa85abbf2abf93f58dcb431e64823fcc7a19a" end depends_on "gnupg" => :test depends_on "oath-toolkit" depends_on "pass" def install system "make", "PREFIX=#{prefix}", "BASHCOMPDIR=#{bash_completion}", "install" end test do (testpath/"batch.gpg").write <<~EOS Key-Type: RSA Key-Length: 2048 Subkey-Type: RSA Subkey-Length: 2048 Name-Real: Testing Name-Email: testing@foo.bar Expire-Date: 1d %no-protection %commit EOS begin system Formula["gnupg"].opt_bin/"gpg", "--batch", "--gen-key", "batch.gpg" system "pass", "init", "Testing" require "open3" Open3.popen3("pass", "otp", "insert", "hotp-secret") do |stdin, _, _| stdin.write "otpauth://hotp/hotp-secret?secret=AAAAAAAAAAAAAAAA&counter=1&issuer=hotp-secret" stdin.close end assert_equal "073348", shell_output("pass otp show hotp-secret").strip ensure system Formula["gnupg"].opt_bin/"gpgconf", "--kill", "gpg-agent" end end end