Skip to content

Commit

Permalink
Changed bitbucket tests to use kosli-dev and not ewelina kosli-dev/se…
Browse files Browse the repository at this point in the history
…rver#2461 (#366)

* Works with kosli-dev and user tore1

* Moved bitbucket username out as a secret since it has to match the password for that user

* Removed ewelinz

* Added bitbucket username to github workflows

* Added missing bitbucket username
  • Loading branch information
ToreMerkely authored Oct 21, 2024
1 parent d555b62 commit f29f037
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 69 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
azure_access_token: ${{ secrets.KOSLI_AZURE_TOKEN }}
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_client_secret: ${{ secrets.AZURE_CLIENT_SECRET }}
bitbucket_username: ${{ secrets.KOSLI_BITBUCKET_USERNAME }}
bitbucket_password: ${{ secrets.KOSLI_BITBUCKET_PASSWORD }}
jira_api_token: ${{ secrets.KOSLI_JIRA_API_TOKEN }}
slack_webhook: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
azure_access_token: ${{ secrets.KOSLI_AZURE_TOKEN }}
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_client_secret: ${{ secrets.AZURE_CLIENT_SECRET }}
bitbucket_username: ${{ secrets.KOSLI_BITBUCKET_USERNAME }}
bitbucket_password: ${{ secrets.KOSLI_BITBUCKET_PASSWORD }}
slack_webhook: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
slack_channel: ci-failures
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ on:
required: true
azure_client_secret:
required: true
bitbucket_username:
required: true
bitbucket_password:
required: true
jira_api_token:
Expand Down Expand Up @@ -131,6 +133,7 @@ jobs:
KOSLI_GITHUB_TOKEN: ${{ secrets.github_access_token }}
KOSLI_GITLAB_TOKEN: ${{ secrets.gitlab_access_token }}
KOSLI_AZURE_TOKEN: ${{ secrets.azure_access_token }}
KOSLI_BITBUCKET_USERNAME: ${{ secrets.bitbucket_username }}
KOSLI_BITBUCKET_PASSWORD: ${{ secrets.bitbucket_password }}
KOSLI_JIRA_API_TOKEN: ${{ secrets.jira_api_token }}
INTEGRATION_TEST_AZURE_CLIENT_SECRET: ${{ secrets.azure_client_secret }}
Expand Down
14 changes: 7 additions & 7 deletions cmd/kosli/assertPRBitbucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ func (suite *AssertPRBitbucketCommandTestSuite) TestAssertPRBitbucketCmd() {
tests := []cmdTestCase{
{
name: "assert Bitbucket PR evidence passes when commit has a PR in bitbucket",
cmd: `assert pullrequest bitbucket --bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test
--commit 2492011ef04a9da09d35be706cf6a4c5bc6f1e69` + suite.defaultKosliArguments,
golden: "found [1] pull request(s) in Bitbucket for commit: 2492011ef04a9da09d35be706cf6a4c5bc6f1e69\n",
cmd: `assert pullrequest bitbucket --bitbucket-workspace kosli-dev --repository cli-test
--commit fd54040fc90e7e83f7b152619bfa18917b72c34f` + suite.defaultKosliArguments,
golden: "found [1] pull request(s) in Bitbucket for commit: fd54040fc90e7e83f7b152619bfa18917b72c34f\n",
},
{
wantError: true,
name: "assert Bitbucket PR evidence fails when commit has no PRs in bitbucket",
cmd: `assert pullrequest bitbucket --bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test
--commit cb6ec5fcbb25b1ebe4859d35ab7995ab973f894c` + suite.defaultKosliArguments,
golden: "Error: assert failed: found no pull request(s) in Bitbucket for commit: cb6ec5fcbb25b1ebe4859d35ab7995ab973f894c\n",
cmd: `assert pullrequest bitbucket --bitbucket-workspace kosli-dev --repository cli-test
--commit 3dce097040987c4693d2e4be817474d9d0063c93` + suite.defaultKosliArguments,
golden: "Error: assert failed: found no pull request(s) in Bitbucket for commit: 3dce097040987c4693d2e4be817474d9d0063c93\n",
},
{
wantError: true,
name: "assert Bitbucket PR evidence fails when commit does not exist",
cmd: `assert pullrequest bitbucket --bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test
cmd: `assert pullrequest bitbucket --bitbucket-workspace kosli-dev --repository cli-test
--commit 19aab7f063147614451c88969602a10afba123ab` + suite.defaultKosliArguments,
golden: "Error: map[error:map[message:Resource not found] type:error]\n",
},
Expand Down
20 changes: 10 additions & 10 deletions cmd/kosli/attestPRBitbucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func (suite *AttestBitbucketPRCommandTestSuite) SetupTest() {
var err error
suite.tmpDir, err = os.MkdirTemp("", "testDir")
require.NoError(suite.T(), err)
_, err = testHelpers.CloneGitRepo("https://bitbucket.org/ewelinawilkosz/cli-test.git", suite.tmpDir)
_, err = testHelpers.CloneGitRepo("https://bitbucket.org/kosli-dev/cli-test.git", suite.tmpDir)
require.NoError(suite.T(), err)

suite.defaultKosliArguments = fmt.Sprintf(" --flow %s --trail %s --repo-root %s --commit 2492011ef04a9da09d35be706cf6a4c5bc6f1e69 --host %s --org %s --api-token %s", suite.flowName, suite.trailName, suite.tmpDir, global.Host, global.Org, global.ApiToken)
suite.defaultKosliArguments = fmt.Sprintf(" --flow %s --trail %s --repo-root %s --commit fd54040fc90e7e83f7b152619bfa18917b72c34f --host %s --org %s --api-token %s", suite.flowName, suite.trailName, suite.tmpDir, global.Host, global.Org, global.ApiToken)
CreateFlowWithTemplate(suite.flowName, "testdata/valid_template.yml", suite.T())
BeginTrail(suite.trailName, suite.flowName, "", suite.T())
CreateArtifactOnTrail(suite.flowName, suite.trailName, "cli", suite.artifactFingerprint, "file1", suite.T())
Expand All @@ -62,7 +62,7 @@ func (suite *AttestBitbucketPRCommandTestSuite) TestAttestBitbucketPRCmd() {
wantError: true,
name: "fails when missing a required flags",
cmd: fmt.Sprintf("attest pullrequest bitbucket foo -t file %s", suite.defaultKosliArguments),
golden: "Error: required flag(s) \"bitbucket-username\", \"bitbucket-workspace\", \"name\", \"repository\" not set\n",
golden: "Error: required flag(s) \"bitbucket-workspace\", \"name\", \"repository\" not set\n",
},
{
wantError: true,
Expand All @@ -80,43 +80,43 @@ func (suite *AttestBitbucketPRCommandTestSuite) TestAttestBitbucketPRCmd() {
wantError: true,
name: "attesting against an artifact that does not exist fails",
cmd: fmt.Sprintf(`attest pullrequest bitbucket --fingerprint 1234e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9 --name foo
--bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test %s`, suite.defaultKosliArguments),
--bitbucket-workspace kosli-dev --repository cli-test %s`, suite.defaultKosliArguments),
goldenRegex: "found 1 pull request\\(s\\) for commit: .*\nError: Artifact with fingerprint 1234e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9 does not exist in trail \"test-123\" of flow \"attest-bitbucket-pr\" belonging to organization \"docs-cmd-test-user\"\n",
},
{
name: "can attest bitbucket pr against an artifact using artifact name and --artifact-type",
cmd: fmt.Sprintf(`attest pullrequest bitbucket testdata/file1 --artifact-type file --name foo
--bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test %s`, suite.defaultKosliArguments),
--bitbucket-workspace kosli-dev --repository cli-test %s`, suite.defaultKosliArguments),
goldenRegex: "found 1 pull request\\(s\\) for commit: .*\nbitbucket pull request attestation 'foo' is reported to trail: test-123\n",
},
{
name: "can attest bitbucket pr against an artifact using artifact name and --artifact-type when --name does not exist in the trail template",
cmd: fmt.Sprintf(`attest pullrequest bitbucket testdata/file1 --artifact-type file --name bar
--bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test %s`, suite.defaultKosliArguments),
--bitbucket-workspace kosli-dev --repository cli-test %s`, suite.defaultKosliArguments),
goldenRegex: "found 1 pull request\\(s\\) for commit: .*\nbitbucket pull request attestation 'bar' is reported to trail: test-123\n",
},
{
name: "can attest bitbucket pr against an artifact using --fingerprint",
cmd: fmt.Sprintf(`attest pullrequest bitbucket --fingerprint 7509e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9 --name foo
--bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test %s`, suite.defaultKosliArguments),
--bitbucket-workspace kosli-dev --repository cli-test %s`, suite.defaultKosliArguments),
goldenRegex: "found 1 pull request\\(s\\) for commit: .*\nbitbucket pull request attestation 'foo' is reported to trail: test-123\n",
},
{
name: "can attest bitbucket pr against a trail",
cmd: fmt.Sprintf(`attest pullrequest bitbucket --name bar
--bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test %s`, suite.defaultKosliArguments),
--bitbucket-workspace kosli-dev --repository cli-test %s`, suite.defaultKosliArguments),
goldenRegex: "found 1 pull request\\(s\\) for commit: .*\nbitbucket pull request attestation 'bar' is reported to trail: test-123\n",
},
{
name: "can attest bitbucket pr against a trail when name is not found in the trail template",
cmd: fmt.Sprintf(`attest pullrequest bitbucket --name additional
--bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test %s`, suite.defaultKosliArguments),
--bitbucket-workspace kosli-dev --repository cli-test %s`, suite.defaultKosliArguments),
goldenRegex: "found 1 pull request\\(s\\) for commit: .*\nbitbucket pull request attestation 'additional' is reported to trail: test-123\n",
},
{
name: "can attest bitbucket pr against an artifact it is created using dot syntax in --name",
cmd: fmt.Sprintf(`attest pullrequest bitbucket --name cli.foo
--bitbucket-username ewelinawilkosz --bitbucket-workspace ewelinawilkosz --repository cli-test %s`, suite.defaultKosliArguments),
--bitbucket-workspace kosli-dev --repository cli-test %s`, suite.defaultKosliArguments),
goldenRegex: "found 1 pull request\\(s\\) for commit: .*\nbitbucket pull request attestation 'foo' is reported to trail: test-123\n",
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/kosli/cli_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ func (suite *CliUtilsTestSuite) TestDefaultValue() {
ci: circleci,
flag: "commit-url",
unsetTestsEnvVar: true,
envVars: map[string]string{"CIRCLE_REPOSITORY_URL": "[email protected]:ewelinawilkosz/cli-test.git", "CIRCLE_SHA1": "2492011ef04a9da09d35be706cf6a4c5bc6f1e69"},
envVars: map[string]string{"CIRCLE_REPOSITORY_URL": "[email protected]:kosli-dev/cli-test.git", "CIRCLE_SHA1": "fd54040fc90e7e83f7b152619bfa18917b72c34f"},
},
want: "https://bitbucket.org/ewelinawilkosz/cli-test/commits/2492011ef04a9da09d35be706cf6a4c5bc6f1e69",
want: "https://bitbucket.org/kosli-dev/cli-test/commits/fd54040fc90e7e83f7b152619bfa18917b72c34f",
},
{
name: "Lookup commit-url for CircleCI with a repo that is not from bitbucket returns correct url (with '/commit/')",
Expand Down
Loading

0 comments on commit f29f037

Please sign in to comment.