-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -65,3 +65,59 @@ func TestAccBitbucketDeployKeyDataSource_basic(t *testing.T) { | |
}, | ||
}) | ||
} | ||
|
||
func TestAccBitbucketDeployKeyDataSource_keyWithComment(t *testing.T) { | ||
workspaceSlug := os.Getenv("BITBUCKET_USERNAME") | ||
projectName := "tf-acc-test-" + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) | ||
projectKey := strings.ToUpper(acctest.RandStringFromCharSet(3, acctest.CharSetAlpha)) | ||
repoName := "tf-acc-test-" + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) | ||
deployKeyLabel := "TF ACC Test Deploy Key" | ||
deployKeyPublicSSHKey := "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAK/b1cHHDr/TEV1JGQl+WjCwStKG6Bhrv0rFpEsYlyTBm1fzN0VOJJYn4ZOPCPJwqse6fGbXntEs+BbXiptR+++HycVgl65TMR0b5ul5AgwrVdZdT7qjCOCgaSV74/9xlHDK8oqgGnfA7ZoBBU+qpVyaloSjBdJfLtPY/xqj4yHnXKYzrtn/uFc4Kp9Tb7PUg9Io3qohSTGJGVHnsVblq/rToJG7L5xIo0OxK0SJSQ5vuId93ZuFZrCNMXj8JDHZeSEtjJzpRCBEXHxpOPhAcbm4MzULgkFHhAVgp4JbkrT99/wpvZ7r9AdkTg7HGqL3rlaDrEcWfL7Lu6TnhBdq5 [email protected]" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: fmt.Sprintf(` | ||
data "bitbucket_workspace" "testacc" { | ||
id = "%s" | ||
} | ||
resource "bitbucket_project" "testacc" { | ||
workspace = data.bitbucket_workspace.testacc.id | ||
name = "%s" | ||
key = "%s" | ||
is_private = true | ||
} | ||
resource "bitbucket_repository" "testacc" { | ||
workspace = data.bitbucket_workspace.testacc.id | ||
project_key = bitbucket_project.testacc.key | ||
name = "%s" | ||
} | ||
resource "bitbucket_deploy_key" "testacc" { | ||
workspace = data.bitbucket_workspace.testacc.id | ||
repository = bitbucket_repository.testacc.name | ||
label = "%s" | ||
key = "%s" | ||
} | ||
data "bitbucket_deploy_key" "testacc" { | ||
id = bitbucket_deploy_key.testacc.id | ||
workspace = data.bitbucket_workspace.testacc.id | ||
repository = bitbucket_repository.testacc.name | ||
}`, workspaceSlug, projectName, projectKey, repoName, deployKeyLabel, deployKeyPublicSSHKey), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.bitbucket_deploy_key.testacc", "workspace", workspaceSlug), | ||
resource.TestCheckResourceAttr("data.bitbucket_deploy_key.testacc", "repository", repoName), | ||
resource.TestCheckResourceAttr("data.bitbucket_deploy_key.testacc", "label", deployKeyLabel), | ||
resource.TestCheckResourceAttr("data.bitbucket_deploy_key.testacc", "key", deployKeyPublicSSHKey), | ||
|
||
resource.TestCheckResourceAttrSet("data.bitbucket_deploy_key.testacc", "id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -58,3 +58,52 @@ func TestAccBitbucketDeployKeyResource_basic(t *testing.T) { | |
}, | ||
}) | ||
} | ||
|
||
func TestAccBitbucketDeployKeyResource_keyWithComment(t *testing.T) { | ||
workspaceSlug := os.Getenv("BITBUCKET_USERNAME") | ||
projectName := "tf-acc-test-" + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) | ||
projectKey := strings.ToUpper(acctest.RandStringFromCharSet(3, acctest.CharSetAlpha)) | ||
repoName := "tf-acc-test-" + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) | ||
deployKeyLabel := "TF ACC Test Deploy Key" | ||
deployKeyPublicSSHKey := "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAK/b1cHHDr/TEV1JGQl+WjCwStKG6Bhrv0rFpEsYlyTBm1fzN0VOJJYn4ZOPCPJwqse6fGbXntEs+BbXiptR+++HycVgl65TMR0b5ul5AgwrVdZdT7qjCOCgaSV74/9xlHDK8oqgGnfA7ZoBBU+qpVyaloSjBdJfLtPY/xqj4yHnXKYzrtn/uFc4Kp9Tb7PUg9Io3qohSTGJGVHnsVblq/rToJG7L5xIo0OxK0SJSQ5vuId93ZuFZrCNMXj8JDHZeSEtjJzpRCBEXHxpOPhAcbm4MzULgkFHhAVgp4JbkrT99/wpvZ7r9AdkTg7HGqL3rlaDrEcWfL7Lu6TnhBdq5 [email protected]" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: fmt.Sprintf(` | ||
data "bitbucket_workspace" "testacc" { | ||
id = "%s" | ||
} | ||
resource "bitbucket_project" "testacc" { | ||
workspace = data.bitbucket_workspace.testacc.id | ||
name = "%s" | ||
key = "%s" | ||
} | ||
resource "bitbucket_repository" "testacc" { | ||
workspace = data.bitbucket_workspace.testacc.id | ||
project_key = bitbucket_project.testacc.key | ||
name = "%s" | ||
} | ||
resource "bitbucket_deploy_key" "testacc" { | ||
workspace = data.bitbucket_workspace.testacc.id | ||
repository = bitbucket_repository.testacc.name | ||
label = "%s" | ||
key = "%s" | ||
}`, workspaceSlug, projectName, projectKey, repoName, deployKeyLabel, deployKeyPublicSSHKey), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("bitbucket_deploy_key.testacc", "workspace", workspaceSlug), | ||
resource.TestCheckResourceAttr("bitbucket_deploy_key.testacc", "repository", repoName), | ||
resource.TestCheckResourceAttr("bitbucket_deploy_key.testacc", "label", deployKeyLabel), | ||
resource.TestCheckResourceAttr("bitbucket_deploy_key.testacc", "key", deployKeyPublicSSHKey), | ||
|
||
resource.TestCheckResourceAttrSet("bitbucket_deploy_key.testacc", "id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |