-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix resolution of deploy-service url
When there are more than one shared domains, presented in the landscape, the logic of finding the correct one, was assuming that the first one is the correct. However, this is not true all the times as the first one could not be the correct one. This commit introduces a mechanism for pinging the domains till the right one responds with 200 OK status code. BUG: LMCROSSITXSADEPLOY-833
- Loading branch information
1 parent
be6fb78
commit 5e256c6
Showing
7 changed files
with
186 additions
and
14 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package util_test | ||
|
||
import ( | ||
"github.com/SAP/cf-mta-plugin/util" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("UriBuilderTest", func() { | ||
Describe("BuildUriTest", func() { | ||
const hostName = "test-host" | ||
const scheme = "test-scheme" | ||
const path = "test-path" | ||
|
||
Context("no scheme and host are provided", func() { | ||
It("should return an error", func() { | ||
uriBuilder := util.NewUriBuilder().SetPath(path) | ||
_, err := uriBuilder.Build() | ||
|
||
Expect(err).Should(MatchError("The host or scheme could not be empty")) | ||
}) | ||
}) | ||
Context("when scheme and path are provided", func() { | ||
It("should return an error", func() { | ||
uriBuilder := util.NewUriBuilder().SetScheme(scheme).SetPath(path) | ||
_, err := uriBuilder.Build() | ||
|
||
Expect(err).Should(MatchError("The host or scheme could not be empty")) | ||
}) | ||
}) | ||
Context("when scheme, host and path are provided", func() { | ||
It("should the built uri", func() { | ||
uriBuilder := util.NewUriBuilder().SetHost(hostName).SetScheme(scheme).SetPath(path) | ||
uri, err := uriBuilder.Build() | ||
|
||
Expect(uri).To(Equal("test-scheme://test-host/test-path")) | ||
Expect(err).To(BeNil()) | ||
}) | ||
}) | ||
|
||
}) | ||
}) |
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fakes | ||
|
||
import "github.com/SAP/cf-mta-plugin/util" | ||
|
||
type fakeHttpGetExecutor struct{ | ||
statusCode int | ||
err error | ||
} | ||
|
||
func NewFakeHttpGetExecutor(statusCode int, err error) util.HttpSimpleGetExecutor{ | ||
return &fakeHttpGetExecutor{statusCode: statusCode, err: err} | ||
} | ||
|
||
func (f fakeHttpGetExecutor) ExecuteGetRequest(url string) (int, error) { | ||
return f.statusCode, f.err | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package util | ||
|
||
import ( | ||
"net/http" | ||
) | ||
|
||
type HttpSimpleGetExecutor interface { | ||
ExecuteGetRequest(url string) (int, error) | ||
} | ||
|
||
type SimpleGetExecutor struct { | ||
} | ||
|
||
func NewSimpleGetExecutor() SimpleGetExecutor { | ||
return SimpleGetExecutor{} | ||
} | ||
|
||
func (executor SimpleGetExecutor) ExecuteGetRequest(url string) (int, error) { | ||
resp, err := http.Get(url) | ||
if err != nil { | ||
return -1, err | ||
} | ||
defer resp.Body.Close() | ||
return resp.StatusCode, nil | ||
} |