|
517 | 517 | expectations: exp{ |
518 | 518 | filesExist("bin/cashapp-private-pkg.sh"), |
519 | 519 | }}, |
| 520 | + {name: "GitHubTokenAuthWithGHCliFails", |
| 521 | + preparations: prep{ |
| 522 | + fixture("github_token_auth"), |
| 523 | + activateWithMocks("."), |
| 524 | + mockGitHub( |
| 525 | + github.WithRequiredToken("mock-gh-token"), |
| 526 | + github.WithMockRelease(github.MockRelease{ |
| 527 | + Repo: "cashapp/hermit-packages-private", |
| 528 | + TagName: "v1.0.0", |
| 529 | + Name: "cashapp-private-pkg-1.0.0.tar.gz", |
| 530 | + Files: []string{"testdata/github_token_auth/packages/cashapp-private-pkg.sh"}, |
| 531 | + }), |
| 532 | + ), |
| 533 | + }, |
| 534 | + script: ` |
| 535 | + # Make sure the gh mock is executable |
| 536 | + chmod +x mocks/gh |
| 537 | +
|
| 538 | + # Configure to use gh CLI auth |
| 539 | + printf "gh-cli-auth = true\n" > "$HERMIT_USER_CONFIG" |
| 540 | +
|
| 541 | + # Set the environment variable to make gh auth fail |
| 542 | + export GH_AUTH_FAIL=1 |
| 543 | +
|
| 544 | + # Install should fail because gh cli auth fails and no env var is set |
| 545 | + hermit install cashapp-private-pkg || true |
| 546 | +
|
| 547 | + # Verify gh CLI was called and failed |
| 548 | + assert test -f gh-failures |
| 549 | + assert grep -q "gh auth token failed" gh-failures |
| 550 | +
|
| 551 | + # Now unset the failure flag and set environment token as fallback |
| 552 | + unset GH_AUTH_FAIL |
| 553 | + export HERMIT_GITHUB_TOKEN="mock-gh-token" |
| 554 | +
|
| 555 | + # Install should succeed with env var |
| 556 | + hermit install cashapp-private-pkg |
| 557 | +
|
| 558 | + # Verify package was installed and works |
| 559 | + assert test "$(cashapp-private-pkg.sh)" = "cashapp-private-pkg 1.0.0" |
| 560 | + `, |
| 561 | + expectations: exp{ |
| 562 | + filesExist("bin/cashapp-private-pkg.sh"), |
| 563 | + outputContains("gh auth failed: no oauth token found for github.com"), |
| 564 | + }}, |
520 | 565 | } |
521 | 566 |
|
522 | 567 | checkForShells(t) |
|
0 commit comments