(t *testing.T)
| 192 | } |
| 193 | |
| 194 | func TestCreateUpdatePasswordRemote(t *testing.T) { |
| 195 | ctx := context.Background() |
| 196 | defer testConfigFile(t, simpleOptions, "update.conf")() |
| 197 | |
| 198 | for _, doObscure := range []bool{false, true} { |
| 199 | for _, noObscure := range []bool{false, true} { |
| 200 | if doObscure && noObscure { |
| 201 | break |
| 202 | } |
| 203 | t.Run(fmt.Sprintf("doObscure=%v,noObscure=%v", doObscure, noObscure), func(t *testing.T) { |
| 204 | opt := config.UpdateRemoteOpt{ |
| 205 | Obscure: doObscure, |
| 206 | NoObscure: noObscure, |
| 207 | } |
| 208 | _, err := config.CreateRemote(ctx, "test2", "config_test_remote", rc.Params{ |
| 209 | "bool": true, |
| 210 | "pass": "potato", |
| 211 | }, opt) |
| 212 | require.NoError(t, err) |
| 213 | |
| 214 | assert.Equal(t, []string{"test2"}, config.Data().GetSectionList()) |
| 215 | assert.Equal(t, "config_test_remote", config.GetValue("test2", "type")) |
| 216 | assert.Equal(t, "true", config.GetValue("test2", "bool")) |
| 217 | gotPw := config.GetValue("test2", "pass") |
| 218 | if !noObscure { |
| 219 | gotPw = obscure.MustReveal(gotPw) |
| 220 | } |
| 221 | assert.Equal(t, "potato", gotPw) |
| 222 | |
| 223 | wantPw := obscure.MustObscure("potato2") |
| 224 | _, err = config.UpdateRemote(ctx, "test2", rc.Params{ |
| 225 | "bool": false, |
| 226 | "pass": wantPw, |
| 227 | "spare": "spare", |
| 228 | }, opt) |
| 229 | require.NoError(t, err) |
| 230 | |
| 231 | assert.Equal(t, []string{"test2"}, config.Data().GetSectionList()) |
| 232 | assert.Equal(t, "config_test_remote", config.GetValue("test2", "type")) |
| 233 | assert.Equal(t, "false", config.GetValue("test2", "bool")) |
| 234 | gotPw = config.GetValue("test2", "pass") |
| 235 | if doObscure { |
| 236 | gotPw = obscure.MustReveal(gotPw) |
| 237 | } |
| 238 | assert.Equal(t, wantPw, gotPw) |
| 239 | |
| 240 | require.NoError(t, config.PasswordRemote(ctx, "test2", rc.Params{ |
| 241 | "pass": "potato3", |
| 242 | })) |
| 243 | |
| 244 | assert.Equal(t, []string{"test2"}, config.Data().GetSectionList()) |
| 245 | assert.Equal(t, "config_test_remote", config.GetValue("test2", "type")) |
| 246 | assert.Equal(t, "false", config.GetValue("test2", "bool")) |
| 247 | assert.Equal(t, "potato3", obscure.MustReveal(config.GetValue("test2", "pass"))) |
| 248 | }) |
| 249 | } |
| 250 | } |
| 251 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…