Skip to content

Commit 4a09285

Browse files
committed
#23 #25 Tune client side timeout and add keycloak-less support
1 parent f2d3129 commit 4a09285

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

cmd/help.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (c *helpCommand) Execute() {
3333
fmt.Println("Args: ")
3434
fmt.Println(" <apiName:apiVersion> Exemple: 'Beer Catalog API:0.9'")
3535
fmt.Println(" <testEndpoint> URL where is deployed implementation to test")
36-
fmt.Println(" <runner> Test strategy (one of: HTTP, SOAP, SOAP_UI, POSTMAN, OPEN_API_SCHEMA)")
36+
fmt.Println(" <runner> Test strategy (one of: HTTP, SOAP, SOAP_UI, POSTMAN, OPEN_API_SCHEMA, ASYNC_API_SCHEMA, GRPC_PROTOBUF, GRAPHQL_SCHEMA)")
3737
fmt.Println("")
3838
fmt.Println("Flags: ")
3939
fmt.Println(" --microcksURL Microcks API endpoint")

cmd/import.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ func (c *importComamnd) Execute() {
7474
config.Verbose = true
7575
}
7676

77-
//
78-
7977
// Now we seems to be good ...
8078
// First - retrieve the Keycloak URL from Microcks configuration.
8179
mc := connectors.NewMicrocksClient(microcksURL)
@@ -85,14 +83,16 @@ func (c *importComamnd) Execute() {
8583
os.Exit(1)
8684
}
8785

88-
// Second - retrieve an OAuth token using Keycloak Client.
89-
kc := connectors.NewKeycloakClient(keycloakURL, keycloakClientID, keycloakClientSecret)
86+
var oauthToken string = "unauthentifed-token"
87+
if keycloakURL != "null" {
88+
// If Keycloak is enabled, retrieve an OAuth token using Keycloak Client.
89+
kc := connectors.NewKeycloakClient(keycloakURL, keycloakClientID, keycloakClientSecret)
9090

91-
var oauthToken string
92-
oauthToken, err = kc.ConnectAndGetToken()
93-
if err != nil {
94-
fmt.Printf("Got error when invoking Keycloack client: %s", err)
95-
os.Exit(1)
91+
oauthToken, err = kc.ConnectAndGetToken()
92+
if err != nil {
93+
fmt.Printf("Got error when invoking Keycloack client: %s", err)
94+
os.Exit(1)
95+
}
9696
}
9797

9898
// Then - for each specificationFile, upload the artifact on Microcks Server.

cmd/test.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,18 @@ func (c *testComamnd) Execute() {
131131
os.Exit(1)
132132
}
133133

134-
// Second - retrieve an OAuth token using Keycloak Client.
135-
kc := connectors.NewKeycloakClient(keycloakURL, keycloakClientID, keycloakClientSecret)
134+
var oauthToken string = "unauthentifed-token"
135+
if keycloakURL != "null" {
136+
// If Keycloak is enabled, retrieve an OAuth token using Keycloak Client.
137+
kc := connectors.NewKeycloakClient(keycloakURL, keycloakClientID, keycloakClientSecret)
136138

137-
var oauthToken string
138-
oauthToken, err = kc.ConnectAndGetToken()
139-
if err != nil {
140-
fmt.Printf("Got error when invoking Keycloack client: %s", err)
141-
os.Exit(1)
139+
oauthToken, err = kc.ConnectAndGetToken()
140+
if err != nil {
141+
fmt.Printf("Got error when invoking Keycloack client: %s", err)
142+
os.Exit(1)
143+
}
144+
//fmt.Printf("Retrieve OAuthToken: %s", oauthToken)
142145
}
143-
//fmt.Printf("Retrieve OAuthToken: %s", oauthToken)
144146

145147
// Then - launch the test on Microcks Server.
146148
mc.SetOAuthToken(oauthToken)
@@ -153,10 +155,12 @@ func (c *testComamnd) Execute() {
153155
}
154156
//fmt.Printf("Retrieve TestResult ID: %s", testResultID)
155157

156-
// Finally - wait for some time
157-
// Add 5000ms to wait time as it's now representing the server timeout.
158+
// Finally - wait before checking and loop for some time
159+
time.Sleep(1 * time.Second)
160+
161+
// Add 10.000ms to wait time as it's now representing the server timeout.
158162
now := nowInMilliseconds()
159-
future := now + waitForMilliseconds + 5000
163+
future := now + waitForMilliseconds + 10000
160164

161165
var success = false
162166
for nowInMilliseconds() < future {

0 commit comments

Comments
 (0)