Skip to content

Commit

Permalink
Add provision token tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyb89 committed Nov 12, 2024
1 parent 92ee2dc commit 253491c
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions api/types/provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,114 @@ func TestProvisionTokenV2_CheckAndSetDefaults(t *testing.T) {
},
wantErr: true,
},
{
desc: "bitbucket only workspace",
token: &ProvisionTokenV2{
Metadata: Metadata{
Name: "test",
},
Spec: ProvisionTokenSpecV2{
Roles: []SystemRole{RoleNode},
JoinMethod: JoinMethodBitbucket,
Bitbucket: &ProvisionTokenSpecV2Bitbucket{
Audience: "foo",
IdentityProviderURL: "https://example.com",
Allow: []*ProvisionTokenSpecV2Bitbucket_Rule{
{
WorkspaceUUID: "{foo}",
},
},
},
},
},
wantErr: false,
},
{
desc: "bitbucket only repository",
token: &ProvisionTokenV2{
Metadata: Metadata{
Name: "test",
},
Spec: ProvisionTokenSpecV2{
Roles: []SystemRole{RoleNode},
JoinMethod: JoinMethodBitbucket,
Bitbucket: &ProvisionTokenSpecV2Bitbucket{
Audience: "foo",
IdentityProviderURL: "https://example.com",
Allow: []*ProvisionTokenSpecV2Bitbucket_Rule{
{
RepositoryUUID: "{foo}",
},
},
},
},
},
wantErr: false,
},
{
desc: "bitbucket missing audience",
token: &ProvisionTokenV2{
Metadata: Metadata{
Name: "test",
},
Spec: ProvisionTokenSpecV2{
Roles: []SystemRole{RoleNode},
JoinMethod: JoinMethodBitbucket,
Bitbucket: &ProvisionTokenSpecV2Bitbucket{
IdentityProviderURL: "https://example.com",
Allow: []*ProvisionTokenSpecV2Bitbucket_Rule{
{
WorkspaceUUID: "{foo}",
},
},
},
},
},
wantErr: true,
},
{
desc: "bitbucket missing identity provider",
token: &ProvisionTokenV2{
Metadata: Metadata{
Name: "test",
},
Spec: ProvisionTokenSpecV2{
Roles: []SystemRole{RoleNode},
JoinMethod: JoinMethodBitbucket,
Bitbucket: &ProvisionTokenSpecV2Bitbucket{
Audience: "foo",
Allow: []*ProvisionTokenSpecV2Bitbucket_Rule{
{
WorkspaceUUID: "{foo}",
},
},
},
},
},
wantErr: true,
},
{
desc: "bitbucket missing workspace or repository",
token: &ProvisionTokenV2{
Metadata: Metadata{
Name: "test",
},
Spec: ProvisionTokenSpecV2{
Roles: []SystemRole{RoleNode},
JoinMethod: JoinMethodBitbucket,
Bitbucket: &ProvisionTokenSpecV2Bitbucket{
Audience: "foo",
IdentityProviderURL: "https://example.com",
Allow: []*ProvisionTokenSpecV2Bitbucket_Rule{
{
StepUUID: "{foo}",
},
},
},
},
},
wantErr: true,
},
}

for _, tc := range testcases {
Expand Down

0 comments on commit 253491c

Please sign in to comment.