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/50bb19b186c0d73b5eb37bc89b2e145fd7d876c0 below:

fix cipher passphrase lookup in the environment · orgrim/pg_back@50bb19b · GitHub

@@ -34,7 +34,6 @@ import (

34 34

"io/ioutil"

35 35

"os"

36 36

"runtime"

37 -

"strings"

38 37

"testing"

39 38

"time"

40 39

)

@@ -209,8 +208,6 @@ func TestParseCli(t *testing.T) {

209 208

timeFormat = "2006-01-02_15-04-05"

210 209

}

211 210 212 -

os.Unsetenv("PGBK_PASSPHRASE")

213 - 214 211

var (

215 212

defaults = defaultOptions()

216 213

tests = []struct {

@@ -291,76 +288,6 @@ func TestParseCli(t *testing.T) {

291 288

"",

292 289

"some/path",

293 290

},

294 -

{

295 -

[]string{"--encrypt"},

296 -

options{

297 -

Directory: "/var/backups/postgresql",

298 -

Format: 'c',

299 -

DirJobs: 1,

300 -

CompressLevel: -1,

301 -

Jobs: 1,

302 -

PauseTimeout: 3600,

303 -

PurgeInterval: -30 * 24 * time.Hour,

304 -

PurgeKeep: 0,

305 -

SumAlgo: "none",

306 -

CfgFile: "/etc/pg_back/pg_back.conf",

307 -

TimeFormat: timeFormat,

308 -

Encrypt: true,

309 -

Upload: "none",

310 -

AzureEndpoint: "blob.core.windows.net",

311 -

},

312 -

false,

313 -

false,

314 -

"cannot use an empty passphrase for encryption",

315 -

"",

316 -

},

317 -

{

318 -

[]string{"--encrypt", "--cipher-pass", ""},

319 -

options{

320 -

Directory: "/var/backups/postgresql",

321 -

Format: 'c',

322 -

DirJobs: 1,

323 -

CompressLevel: -1,

324 -

Jobs: 1,

325 -

PauseTimeout: 3600,

326 -

PurgeInterval: -30 * 24 * time.Hour,

327 -

PurgeKeep: 0,

328 -

SumAlgo: "none",

329 -

CfgFile: "/etc/pg_back/pg_back.conf",

330 -

TimeFormat: timeFormat,

331 -

Encrypt: true,

332 -

Upload: "none",

333 -

AzureEndpoint: "blob.core.windows.net",

334 -

},

335 -

false,

336 -

false,

337 -

"cannot use an empty passphrase for encryption",

338 -

"",

339 -

},

340 -

{

341 -

[]string{"--encrypt", "--cipher-pass", "testpass"},

342 -

options{

343 -

Directory: "/var/backups/postgresql",

344 -

Format: 'c',

345 -

DirJobs: 1,

346 -

CompressLevel: -1,

347 -

Jobs: 1,

348 -

PauseTimeout: 3600,

349 -

PurgeInterval: -30 * 24 * time.Hour,

350 -

PurgeKeep: 0,

351 -

SumAlgo: "none",

352 -

CfgFile: "/etc/pg_back/pg_back.conf",

353 -

TimeFormat: timeFormat,

354 -

Encrypt: true,

355 -

CipherPassphrase: "testpass",

356 -

Upload: "none",

357 -

AzureEndpoint: "blob.core.windows.net",

358 -

},

359 -

false,

360 -

false,

361 -

"",

362 -

"",

363 -

},

364 291

{

365 292

[]string{"--upload", "wrong"},

366 293

options{

@@ -437,119 +364,6 @@ func TestParseCli(t *testing.T) {

437 364

}

438 365

}

439 366 440 -

func TestParseCliEnv(t *testing.T) {

441 -

timeFormat := time.RFC3339

442 -

if runtime.GOOS == "windows" {

443 -

timeFormat = "2006-01-02_15-04-05"

444 -

}

445 - 446 -

os.Unsetenv("PGBK_PASSPHRASE")

447 - 448 -

var (

449 -

tests = []struct {

450 -

args []string

451 -

want options

452 -

err string

453 -

env string

454 -

}{

455 -

{

456 -

[]string{"--encrypt"},

457 -

options{

458 -

Directory: "/var/backups/postgresql",

459 -

Format: 'c',

460 -

DirJobs: 1,

461 -

CompressLevel: -1,

462 -

Jobs: 1,

463 -

PauseTimeout: 3600,

464 -

PurgeInterval: -30 * 24 * time.Hour,

465 -

PurgeKeep: 0,

466 -

SumAlgo: "none",

467 -

CfgFile: "/etc/pg_back/pg_back.conf",

468 -

TimeFormat: timeFormat,

469 -

Encrypt: true,

470 -

Upload: "none",

471 -

AzureEndpoint: "blob.core.windows.net",

472 -

},

473 -

"cannot use an empty passphrase for encryption",

474 -

"PGBK_PASSPHRASE=",

475 -

},

476 -

{

477 -

[]string{"--encrypt"},

478 -

options{

479 -

Directory: "/var/backups/postgresql",

480 -

Format: 'c',

481 -

DirJobs: 1,

482 -

CompressLevel: -1,

483 -

Jobs: 1,

484 -

PauseTimeout: 3600,

485 -

PurgeInterval: -30 * 24 * time.Hour,

486 -

PurgeKeep: 0,

487 -

SumAlgo: "none",

488 -

CfgFile: "/etc/pg_back/pg_back.conf",

489 -

TimeFormat: timeFormat,

490 -

Encrypt: true,

491 -

CipherPassphrase: "testpass",

492 -

Upload: "none",

493 -

AzureEndpoint: "blob.core.windows.net",

494 -

},

495 -

"",

496 -

"PGBK_PASSPHRASE=testpass",

497 -

},

498 -

{

499 -

[]string{"--encrypt", "--cipher-pass", "testpass"},

500 -

options{

501 -

Directory: "/var/backups/postgresql",

502 -

Format: 'c',

503 -

DirJobs: 1,

504 -

CompressLevel: -1,

505 -

Jobs: 1,

506 -

PauseTimeout: 3600,

507 -

PurgeInterval: -30 * 24 * time.Hour,

508 -

PurgeKeep: 0,

509 -

SumAlgo: "none",

510 -

CfgFile: "/etc/pg_back/pg_back.conf",

511 -

TimeFormat: timeFormat,

512 -

Encrypt: true,

513 -

CipherPassphrase: "testpass",

514 -

Upload: "none",

515 -

AzureEndpoint: "blob.core.windows.net",

516 -

},

517 -

"",

518 -

"PGBK_PASSPHRASE=testenv",

519 -

},

520 -

}

521 -

)

522 -

for i, st := range tests {

523 -

t.Run(fmt.Sprintf("%v", i), func(t *testing.T) {

524 -

var (

525 -

opts options

526 -

err error

527 -

)

528 - 529 -

// Prepare the environment

530 -

if st.env != "" {

531 -

v := strings.Split(st.env, "=")

532 -

os.Setenv(v[0], v[1])

533 -

}

534 -

// reset pflag default flagset between each sub test

535 -

pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ContinueOnError)

536 - 537 -

// when testing for help or version the usage is output to stderr, discard it with a pipe

538 -

opts, _, err = parseCli(st.args)

539 - 540 -

if err != nil {

541 -

if st.err != err.Error() {

542 -

t.Errorf("got error %v, expected %v", st.err, err)

543 -

}

544 -

} else {

545 -

if diff := cmp.Diff(st.want, opts, cmpopts.EquateEmpty()); diff != "" {

546 -

t.Errorf("ParseCli() mismatch (-want +got):\n%s", diff)

547 -

}

548 -

}

549 -

})

550 -

}

551 -

}

552 - 553 367

func TestLoadConfigurationFile(t *testing.T) {

554 368

timeFormat := time.RFC3339

555 369

if runtime.GOOS == "windows" {


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