Reject setting both OAuth token-URL closures
A Registration that sets both BuildTokenURLForDomain and BuildTokenURLForSite would pass startup but silently use only the first at the OAuth callback (CompleteWithState checks them in order). Reject the combination in Register so the misconfiguration fails loud at process start, matching the existing APIKeyBasicAuth/APIKeyHeader guard. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -109,6 +109,20 @@ func TestRegistry_Register(t *testing.T) {
|
||||
assert.Contains(t, err.Error(), "mutually exclusive")
|
||||
})
|
||||
|
||||
t.Run("BuildTokenURLForDomain and BuildTokenURLForSite mutually exclusive", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
r := provider.NewRegistry()
|
||||
err := r.Register(&provider.Registration{
|
||||
Provider: coredata.ConnectorProviderSlack,
|
||||
DisplayName: "Slack",
|
||||
BuildTokenURLForDomain: func(string) (string, error) { return "", nil },
|
||||
BuildTokenURLForSite: func(string) (string, error) { return "", nil },
|
||||
})
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "mutually exclusive")
|
||||
})
|
||||
|
||||
t.Run("duplicate registration", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user