Skip to content

Commit

Permalink
Disable encryption in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adambabik committed Jul 7, 2024
1 parent 89355c3 commit 3557492
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions internal/command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func init() {
// TODO(adamb): this can be changed. runme must be built
// in the test environment and put into the PATH.
EnvDumpCommand = "env -0"

// We don't have a way to test encryption using overriden [EnvDumpCommand].
envCollectorEnableEncryption = false
}

func testExecuteCommand(
Expand Down
9 changes: 6 additions & 3 deletions internal/command/env_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ func (f *envCollectorFactory) Build() (envCollector, error) {
}

func (f *envCollectorFactory) generateEncryptionKeyAndNonce() ([]byte, []byte, error) {
encKey, err := createEnvEncryptionKey()
key, err := createEnvEncryptionKey()
if err != nil {
return nil, nil, errors.WithMessage(err, "failed to create the encryption key")
}

encNonce, err := createEnvEncryptionKey()
nonce, err := createEnvEncryptionNonce()
if err != nil {
return nil, nil, errors.WithMessage(err, "failed to create the encryption nonce")
}

return encKey, encNonce, nil
return key, nonce, nil
}

type envCollector interface {
Expand Down Expand Up @@ -167,6 +167,9 @@ func (c *envCollectorFile) Diff() (changed []string, deleted []string, _ error)
}

func (c *envCollectorFile) ExtraEnv() []string {
if c.encKey == nil || c.encNonce == nil {
return nil
}
return []string{
envCollectorEncKeyEnvName + "=" + hex.EncodeToString(c.encKey),
envCollectorEncNonceEnvName + "=" + hex.EncodeToString(c.encNonce),
Expand Down
3 changes: 3 additions & 0 deletions internal/command/env_collector_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (c *envCollectorFifo) Diff() (changed []string, deleted []string, _ error)
}

func (c *envCollectorFifo) ExtraEnv() []string {
if c.encKey == nil || c.encNonce == nil {
return nil
}
return []string{
"RUNME_ENCRYPTION_KEY=" + hex.EncodeToString(c.encKey),
"RUNME_ENCRYPTION_NONCE=" + hex.EncodeToString(c.encNonce),
Expand Down

0 comments on commit 3557492

Please sign in to comment.