Repository navigation
bridge, commands: fix credential selection and dangling identity handling #1663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mcepl
wants to merge
12
commits into
git-bug:trunk
Choose a base branch
from
openSUSE-Python:fix/bridge-identity-creds
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
730befa
bridge, commands: handle a dangling user identity gracefully
mcepl d06f79f
bridge/core/auth: list credentials newest first
mcepl e17a620
commands/bridge: add --base-url to "bridge auth add-token"
mcepl 2fc700e
bridge/{github,gitlab}: use iterated credential when caching export c…
mcepl 2c5ed84
bridge/core/auth, commands/bridge: normalize base URLs for credential…
mcepl 0cf26be
bridge: preserve instance URLs and support Jira token credentials
mcepl 4a6aea9
bridge/jira: respect configured authentication mode
mcepl 78e2244
bridge/jira: scope setup credentials and prefer API tokens
mcepl ccd1c2b
bridge/jira: retain the validated credential for synchronization
mcepl f6daa27
test(bridge/jira): separate credential timestamps on Windows
mcepl 1d485f8
bridge/jira: preserve password prompts and allow token rotation
mcepl 98fceb8
bridge/jira: require explicit rotation of validated credentials
mcepl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package core | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/git-bug/git-bug/cache" | ||
| "github.com/git-bug/git-bug/entities/identity" | ||
| "github.com/git-bug/git-bug/entity" | ||
| "github.com/git-bug/git-bug/repository" | ||
| ) | ||
|
|
||
| func TestFinishConfigDanglingUserIdentity(t *testing.T) { | ||
| repo := repository.CreateGoGitTestRepo(t, false) | ||
|
|
||
| // Point the user identity to an identity that doesn't exist in the repo, | ||
| // as happens when the identity has been removed or the config copied over. | ||
| dangling := entity.Id(strings.Repeat("a", 64)) | ||
| require.NoError(t, repo.LocalConfig().StoreString("git-bug.identity", dangling.String())) | ||
|
|
||
| backend, err := cache.NewRepoCacheNoEvents(repo) | ||
| require.NoError(t, err) | ||
| defer backend.Close() | ||
|
|
||
| const metaKey = "test-login" | ||
|
|
||
| err = FinishConfig(backend, metaKey, "jdoe") | ||
| require.NoError(t, err) | ||
|
|
||
| // a new identity tagged with the login must be the current user now | ||
| user, err := backend.GetUserIdentity() | ||
| require.NoError(t, err) | ||
| require.NotEqual(t, dangling, user.Id()) | ||
| require.Equal(t, "jdoe", user.ImmutableMetadata()[metaKey]) | ||
|
|
||
| id, err := identity.GetUserIdentityId(repo) | ||
| require.NoError(t, err) | ||
| require.Equal(t, user.Id(), id) | ||
| } | ||
|
|
||
| func TestFinishConfigDanglingUserIdentityWithExisting(t *testing.T) { | ||
| repo := repository.CreateGoGitTestRepo(t, false) | ||
|
|
||
| backend, err := cache.NewRepoCacheNoEvents(repo) | ||
| require.NoError(t, err) | ||
| defer backend.Close() | ||
|
|
||
| const metaKey = "test-login" | ||
|
|
||
| // Create an identity tagged with the login metadata in the repository | ||
| existing, err := backend.Identities().NewFromGitUserRaw(map[string]string{ | ||
| metaKey: "jdoe", | ||
| }) | ||
| require.NoError(t, err) | ||
|
|
||
| // Set a dangling user identity in git config | ||
| dangling := entity.Id(strings.Repeat("a", 64)) | ||
| require.NoError(t, repo.LocalConfig().StoreString("git-bug.identity", dangling.String())) | ||
|
|
||
| err = FinishConfig(backend, metaKey, "jdoe") | ||
| require.NoError(t, err) | ||
|
|
||
| // the existing identity must have replaced the dangling one as the current user | ||
| user, err := backend.GetUserIdentity() | ||
| require.NoError(t, err) | ||
| require.Equal(t, existing.Id(), user.Id()) | ||
|
|
||
| id, err := identity.GetUserIdentityId(repo) | ||
| require.NoError(t, err) | ||
| require.Equal(t, existing.Id(), id) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.