Documentation
¶
Overview ¶
Package sopstest writes sops encrypted files for tests with the sops command, the way "sops encrypt --encrypted-regex '^(data|binaryData)$'" writes them, to keys generated by the test, so that no private key is kept in the repository.
The tests need sops in PATH: mise.toml pins the version CI tests with, and "mise install" installs it. A test that needs it fails without it rather than being skipped, so that a missing sops is not mistaken for a passing test.
Index ¶
- Constants
- func AddVaultKey(t testing.TB, file []byte, address string) []byte
- func Binary(t testing.TB) string
- func Encrypt(t testing.TB, plaintext string, recipients ...string) []byte
- func EncryptWith(t testing.TB, plaintext string, opts Options, recipients ...string) []byte
- func EncryptWithRegex(t testing.TB, plaintext, regex string, recipients ...string) []byte
- type Options
Constants ¶
const EncryptedRegex = "^(data|binaryData)$"
EncryptedRegex is the rule the documentation tells administrators to use.
Variables ¶
This section is empty.
Functions ¶
func AddVaultKey ¶ added in v0.3.0
AddVaultKey adds a HashiCorp Vault master key at address to the sops metadata of an encrypted file, the way anyone who can write the file can: the message authentication code does not cover the metadata. The data key it claims to hold is made up, so only a request to address shows that it was tried.
func Binary ¶ added in v0.4.0
Binary returns the sops the tests run, and fails the test when there is none.
func Encrypt ¶
Encrypt encrypts a plaintext YAML document to the given age recipients and returns the file sops wrote.
func EncryptWith ¶ added in v0.3.0
EncryptWith is Encrypt with the given settings.
Types ¶
type Options ¶ added in v0.3.0
type Options struct {
// Regex is the encrypted_regex; an empty one encrypts every value.
Regex string
// MACOnlyEncrypted computes the message authentication code over the
// encrypted values only, as "sops --mac-only-encrypted" does.
MACOnlyEncrypted bool
}
Options are the settings of sops a test varies.