-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: xray watch #211
Feature: xray watch #211
Changes from all commits
7809b5a
0e6132d
d4a29b7
09fd8fd
69afc2e
1cd9175
8ecf4f7
070f421
d1d2252
4ef0b47
75a9cbc
ccb28a7
1139426
df5fdbe
8969dab
0a61652
8f319d8
c17b085
0a615d2
14efc5a
128e9d0
38a9f41
dee3850
908ea61
366943b
9d0aa86
226ebc3
f141060
1921286
bc2aa2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ | |
|
||
# IOS | ||
*.DS_Store | ||
|
||
# go coverage | ||
coverage.out |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ import ( | |
"errors" | ||
"flag" | ||
"fmt" | ||
"github.com/jfrog/jfrog-client-go/artifactory/services/utils/tests" | ||
"io/ioutil" | ||
"net/http" | ||
"os" | ||
|
@@ -14,6 +13,8 @@ import ( | |
"testing" | ||
"time" | ||
|
||
"github.com/jfrog/jfrog-client-go/artifactory/services/utils/tests" | ||
|
||
artifactoryAuth "github.com/jfrog/jfrog-client-go/artifactory/auth" | ||
rthttpclient "github.com/jfrog/jfrog-client-go/artifactory/httpclient" | ||
"github.com/jfrog/jfrog-client-go/artifactory/services" | ||
|
@@ -25,12 +26,15 @@ import ( | |
clientutils "github.com/jfrog/jfrog-client-go/utils" | ||
"github.com/jfrog/jfrog-client-go/utils/io/fileutils" | ||
"github.com/jfrog/jfrog-client-go/utils/log" | ||
xrayAuth "github.com/jfrog/jfrog-client-go/xray/auth" | ||
xrayServices "github.com/jfrog/jfrog-client-go/xray/services" | ||
"github.com/mholt/archiver" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var RtUrl *string | ||
var DistUrl *string | ||
var XrayUrl *string | ||
var RtUser *string | ||
var RtPassword *string | ||
var RtApiKey *string | ||
|
@@ -69,6 +73,10 @@ var testsBundleDistributionStatusService *distributionServices.DistributionStatu | |
var testsBundleDeleteLocalService *distributionServices.DeleteLocalReleaseBundleService | ||
var testsBundleDeleteRemoteService *distributionServices.DeleteReleaseBundleService | ||
|
||
// Xray Services | ||
var testsXrayVersionService *xrayServices.VersionService | ||
var testsXrayWatchService *xrayServices.WatchService | ||
|
||
var timestamp = time.Now().Unix() | ||
var trueValue = true | ||
var falseValue = false | ||
|
@@ -84,6 +92,7 @@ const ( | |
func init() { | ||
RtUrl = flag.String("rt.url", "http://localhost:8081/artifactory/", "Artifactory url") | ||
DistUrl = flag.String("rt.distUrl", "", "Distribution url") | ||
XrayUrl = flag.String("rt.xrayUrl", "", "Xray url") | ||
RtUser = flag.String("rt.user", "admin", "Artifactory username") | ||
RtPassword = flag.String("rt.password", "password", "Artifactory password") | ||
RtApiKey = flag.String("rt.apikey", "", "Artifactory user API key") | ||
|
@@ -158,6 +167,14 @@ func createDistributionManager() { | |
testsBundleDeleteRemoteService.DistDetails = distDetails | ||
} | ||
|
||
func createXrayVersionManager() { | ||
xrayDetails := GetXrayDetails() | ||
client, err := rthttpclient.ArtifactoryClientBuilder().SetServiceDetails(&xrayDetails).Build() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that ArtifactoryClientBuilder also needs to be used for Xray, we should rename it to HttpClientBuilder. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @eyalbe4, I understand why you want to move that functionality, but I've noticed a few things.
This sounds like a big change that should go in a separate PR, as it would effect many files under As the Cheers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it @josh-barker-coles. We'll create an issue for this and handle this in a follow up PR. |
||
failOnHttpClientCreation(err) | ||
testsXrayVersionService = xrayServices.NewVersionService(client) | ||
testsXrayVersionService.XrayDetails = xrayDetails | ||
} | ||
|
||
func createArtifactoryCreateLocalRepositoryManager() { | ||
artDetails := GetRtDetails() | ||
client, err := rthttpclient.ArtifactoryClientBuilder().SetServiceDetails(&artDetails).Build() | ||
|
@@ -262,6 +279,14 @@ func createArtifactoryPermissionTargetManager() { | |
testsPermissionTargetService.ArtDetails = artDetails | ||
} | ||
|
||
func createXrayWatchManager() { | ||
XrayDetails := GetXrayDetails() | ||
client, err := rthttpclient.ArtifactoryClientBuilder().SetServiceDetails(&XrayDetails).Build() | ||
failOnHttpClientCreation(err) | ||
testsXrayWatchService = xrayServices.NewWatchService(client) | ||
testsXrayWatchService.XrayDetails = XrayDetails | ||
} | ||
|
||
func failOnHttpClientCreation(err error) { | ||
if err != nil { | ||
log.Error(fmt.Sprintf(HttpClientCreationFailureMessage, err.Error())) | ||
|
@@ -283,6 +308,13 @@ func GetDistDetails() auth.ServiceDetails { | |
return distDetails | ||
} | ||
|
||
func GetXrayDetails() auth.ServiceDetails { | ||
xrayDetails := xrayAuth.NewXrayDetails() | ||
xrayDetails.SetUrl(clientutils.AddTrailingSlashIfNeeded(*XrayUrl)) | ||
setAuthenticationDetail(xrayDetails) | ||
return xrayDetails | ||
} | ||
|
||
func setAuthenticationDetail(details auth.ServiceDetails) { | ||
if !fileutils.IsSshUrl(details.GetUrl()) { | ||
if *RtApiKey != "" { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tests | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestXrayVersion(t *testing.T) { | ||
if *XrayUrl == "" { | ||
t.Skip("Xray is not being tested, skipping...") | ||
} | ||
|
||
version, err := GetXrayDetails().GetVersion() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
if version == "" { | ||
t.Error("Expected a version, got empty string") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this has been added as part of the InitArtifactoryServiceManager function, we should probably rename the function from InitArtifactoryServiceManager to InitServiceManagers.