-
Notifications
You must be signed in to change notification settings - Fork 73
/
azure_test.go
50 lines (42 loc) · 1.91 KB
/
azure_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"github.com/jfrog/frogbot/v2/utils"
"github.com/jfrog/froggit-go/vcsclient"
"github.com/jfrog/froggit-go/vcsutils"
"github.com/stretchr/testify/assert"
"testing"
)
const (
//#nosec G101 -- False positive - no hardcoded credentials.
azureIntegrationTokenEnv = "FROGBOT_TESTS_AZURE_TOKEN"
azureApiEndpoint = "https://dev.azure.com/frogbot-test"
azureGitCloneUrl = "https://frogbot-test@dev.azure.com/frogbot-test/integration/_git/integration"
)
func buildAzureReposClient(t *testing.T, azureToken string) vcsclient.VcsClient {
azureClient, err := vcsclient.NewClientBuilder(vcsutils.AzureRepos).Project(repoName).ApiEndpoint(azureApiEndpoint).Token(azureToken).Build()
assert.NoError(t, err)
return azureClient
}
func buildAzureReposIntegrationTestDetails(t *testing.T, useLocalRepo bool) *IntegrationTestDetails {
integrationRepoToken := getIntegrationToken(t, azureIntegrationTokenEnv)
testDetails := NewIntegrationTestDetails(integrationRepoToken, string(utils.AzureRepos), azureGitCloneUrl, "frogbot-test", useLocalRepo)
testDetails.ApiEndpoint = azureApiEndpoint
return testDetails
}
func azureReposTestsInit(t *testing.T, useLocalRepo bool) (vcsclient.VcsClient, *IntegrationTestDetails) {
testDetails := buildAzureReposIntegrationTestDetails(t, useLocalRepo)
azureClient := buildAzureReposClient(t, testDetails.GitToken)
return azureClient, testDetails
}
func TestAzureRepos_ScanPullRequestIntegration(t *testing.T) {
azureClient, testDetails := azureReposTestsInit(t, false)
runScanPullRequestCmd(t, azureClient, testDetails)
}
func TestAzureRepos_ScanRepositoryIntegration(t *testing.T) {
azureClient, testDetails := azureReposTestsInit(t, false)
runScanRepositoryCmd(t, azureClient, testDetails)
}
func TestAzureRepos_ScanRepositoryWithLocalDirIntegration(t *testing.T) {
azureClient, testDetails := azureReposTestsInit(t, true)
runScanRepositoryCmd(t, azureClient, testDetails)
}