A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/orgrim/pg_back/commit/d29bd1c386631efdf41ec80fe77d1e0dd2683fc9 below:

Pass opts by reference · orgrim/pg_back@d29bd1c · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+52

-2

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+52

-2

lines changed Original file line number Diff line number Diff line change

@@ -168,7 +168,7 @@ func run() (retVal error) {

168 168

// the command line

169 169

opts := mergeCliAndConfigOptions(cliOpts, cliOptions, cliOptList)

170 170 171 -

err = ensureCipherParamsPresent(opts)

171 +

err = ensureCipherParamsPresent(&opts)

172 172

if err != nil {

173 173

return fmt.Errorf("required cipher parameters not present: %w", err)

174 174

}

@@ -696,7 +696,7 @@ func dumper(id int, jobs <-chan *dump, results chan<- *dump, fc chan<- sumFileJo

696 696

}

697 697

}

698 698 699 -

func ensureCipherParamsPresent(opts options) error {

699 +

func ensureCipherParamsPresent(opts *options) error {

700 700

// Nothing needs to be done if we are not encrypting or decrypting

701 701

if !opts.Encrypt && !opts.Decrypt {

702 702

return nil

Original file line number Diff line number Diff line change

@@ -68,3 +68,53 @@ func TestExecPath(t *testing.T) {

68 68

})

69 69

}

70 70

}

71 + 72 +

func TestEnsureCipherParamsPresent_NoEncryptNoDecrypt_NoParams_ReturnsNil(t *testing.T) {

73 +

opts := options{}

74 + 75 +

err := ensureCipherParamsPresent(&opts)

76 +

if err != nil {

77 +

t.Errorf("should not return error")

78 +

}

79 +

}

80 + 81 +

func TestEnsureCipherParamsPresent_NoEncryptNoDecrypt_HasParams_ReturnsNil(t *testing.T) {

82 +

opts := options{

83 +

CipherPublicKey: "foo1",

84 +

CipherPrivateKey: "bar99",

85 +

CipherPassphrase: "secretwords",

86 +

}

87 + 88 +

err := ensureCipherParamsPresent(&opts)

89 +

if err != nil {

90 +

t.Errorf("should not return error")

91 +

}

92 +

}

93 + 94 +

func TestEnsureCipherParamsPresent_Encrypt_NoParams_Failure(t *testing.T) {

95 +

opts := options{

96 +

Encrypt: true,

97 +

CipherPrivateKey: "bar99",

98 +

}

99 + 100 +

err := ensureCipherParamsPresent(&opts)

101 +

if err == nil {

102 +

t.Errorf("should have error about not finding passphrase")

103 +

}

104 +

}

105 + 106 +

func TestEnsureCipherParamsPresent_Encrypt_NoParamsButEnv_Success(t *testing.T) {

107 +

opts := options{

108 +

Encrypt: true,

109 +

}

110 +

t.Setenv("PGBK_CIPHER_PASS", "works")

111 + 112 +

err := ensureCipherParamsPresent(&opts)

113 +

if err != nil {

114 +

t.Errorf("should have read environment variable")

115 +

}

116 + 117 +

if opts.CipherPassphrase != "works" {

118 +

t.Errorf("passphrase was not read correctly from environment")

119 +

}

120 +

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4