|
| 1 | +package copilot |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/1Password/shell-plugins/sdk" |
| 7 | + "github.com/1Password/shell-plugins/sdk/plugintest" |
| 8 | + "github.com/1Password/shell-plugins/sdk/schema/fieldname" |
| 9 | +) |
| 10 | + |
| 11 | +const exampleCopilotToken = "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE" |
| 12 | + |
| 13 | +func TestAuthTokenProvisioner(t *testing.T) { |
| 14 | + plugintest.TestProvisioner(t, AuthToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{ |
| 15 | + "default": { |
| 16 | + ItemFields: map[sdk.FieldName]string{ |
| 17 | + fieldname.Token: exampleCopilotToken, |
| 18 | + }, |
| 19 | + ExpectedOutput: sdk.ProvisionOutput{ |
| 20 | + Environment: map[string]string{ |
| 21 | + "COPILOT_GITHUB_TOKEN": exampleCopilotToken, |
| 22 | + }, |
| 23 | + }, |
| 24 | + }, |
| 25 | + }) |
| 26 | +} |
| 27 | + |
| 28 | +func TestAuthTokenImporter(t *testing.T) { |
| 29 | + plugintest.TestImporter(t, AuthToken().Importer, map[string]plugintest.ImportCase{ |
| 30 | + "COPILOT_GITHUB_TOKEN": { |
| 31 | + Environment: map[string]string{ |
| 32 | + "COPILOT_GITHUB_TOKEN": exampleCopilotToken, |
| 33 | + }, |
| 34 | + ExpectedCandidates: []sdk.ImportCandidate{ |
| 35 | + { |
| 36 | + Fields: map[sdk.FieldName]string{ |
| 37 | + fieldname.Token: exampleCopilotToken, |
| 38 | + }, |
| 39 | + }, |
| 40 | + }, |
| 41 | + }, |
| 42 | + "GITHUB_TOKEN ignored": { |
| 43 | + Environment: map[string]string{ |
| 44 | + "COPILOT_GITHUB_TOKEN": "", |
| 45 | + "GITHUB_TOKEN": exampleCopilotToken, |
| 46 | + }, |
| 47 | + ExpectedCandidates: []sdk.ImportCandidate{}, |
| 48 | + }, |
| 49 | + }) |
| 50 | +} |
0 commit comments