|
| 1 | +package github |
| 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 | +func TestGitHubCLIProvisioner(t *testing.T) { |
| 12 | + plugintest.TestProvisioner(t, GitHubCLIProvisioner{}, map[string]plugintest.ProvisionCase{ |
| 13 | + "github.com": { |
| 14 | + ItemFields: map[sdk.FieldName]string{ |
| 15 | + fieldname.Token: "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 16 | + }, |
| 17 | + ExpectedOutput: sdk.ProvisionOutput{ |
| 18 | + Environment: map[string]string{ |
| 19 | + "GH_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 20 | + "GITHUB_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 21 | + }, |
| 22 | + }, |
| 23 | + }, |
| 24 | + "github.com with explicit host": { |
| 25 | + ItemFields: map[sdk.FieldName]string{ |
| 26 | + fieldname.Token: "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 27 | + fieldname.Host: "github.com", |
| 28 | + }, |
| 29 | + ExpectedOutput: sdk.ProvisionOutput{ |
| 30 | + Environment: map[string]string{ |
| 31 | + "GH_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 32 | + "GITHUB_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 33 | + }, |
| 34 | + }, |
| 35 | + }, |
| 36 | + "GitHub Enterprise Server": { |
| 37 | + ItemFields: map[sdk.FieldName]string{ |
| 38 | + fieldname.Token: "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 39 | + fieldname.Host: "enterprise.github.com", |
| 40 | + }, |
| 41 | + ExpectedOutput: sdk.ProvisionOutput{ |
| 42 | + Environment: map[string]string{ |
| 43 | + "GH_ENTERPRISE_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 44 | + "GITHUB_ENTERPRISE_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 45 | + "GH_HOST": "enterprise.github.com", |
| 46 | + }, |
| 47 | + }, |
| 48 | + }, |
| 49 | + "GitHub Enterprise Cloud": { |
| 50 | + ItemFields: map[sdk.FieldName]string{ |
| 51 | + fieldname.Token: "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 52 | + fieldname.Host: "company.ghe.com", |
| 53 | + }, |
| 54 | + ExpectedOutput: sdk.ProvisionOutput{ |
| 55 | + Environment: map[string]string{ |
| 56 | + "GH_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 57 | + "GITHUB_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 58 | + "GH_HOST": "company.ghe.com", |
| 59 | + }, |
| 60 | + }, |
| 61 | + }, |
| 62 | + "github.localhost": { |
| 63 | + ItemFields: map[sdk.FieldName]string{ |
| 64 | + fieldname.Token: "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 65 | + fieldname.Host: "github.localhost", |
| 66 | + }, |
| 67 | + ExpectedOutput: sdk.ProvisionOutput{ |
| 68 | + Environment: map[string]string{ |
| 69 | + "GH_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 70 | + "GITHUB_TOKEN": "github_pat_OYXGsaLFxgNy9msXs44LFNzg3wh0VsXRGycViVc0iKPOqczc1QKlB3ZVVrm5ESukqKR8nE3jzPBEXAMPLE", |
| 71 | + "GH_HOST": "github.localhost", |
| 72 | + }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + }) |
| 76 | +} |
0 commit comments