Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultTestConfig(dbConfig db.Config, metronAddress string, fixturesPath string) config.Config
- func MakeAndDoHTTPSRequest(method string, endpoint string, body io.Reader, c *tls.Config) *http.Response
- func MakeAndDoRequest(method string, endpoint string, body io.Reader) *http.Response
- func SplitUAAHostPort() (string, int)
- func StartPolicyServer(policyServerPath string, conf config.Config) *gexec.Session
- func VerifyTCPConnection(address string) error
- func WriteConfigFile(policyServerConfig config.Config) string
Constants ¶
View Source
const DEFAULT_TIMEOUT = "5s"
Variables ¶
View Source
var MockCCServer = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Header["Authorization"][0] != "bearer valid-token" { w.WriteHeader(http.StatusUnauthorized) return } if r.URL.Path == "/v3/apps" { if strings.Contains(r.URL.RawQuery, "app-guid-not-in-my-spaces") { w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.AppsV3TwoSpaces)) return } if strings.Contains(r.URL.RawQuery, "live-app-1-guid") && !strings.Contains(r.URL.RawQuery, "live-app-2-guid") { w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.AppsV3LiveApp1GUID)) return } if strings.Contains(r.URL.RawQuery, "live-app-2-guid") && !strings.Contains(r.URL.RawQuery, "live-app-1-guid") { w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.AppsV3LiveApp2GUID)) return } w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.AppsV3OneSpace)) return } if r.URL.Path == "/v2/spaces/space-1-guid" { w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.Space1)) return } if r.URL.Path == "/v2/spaces/space-2-guid" { w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.Space2)) return } if r.URL.Path == "/v2/spaces" { if strings.Contains(r.URL.RawQuery, "space-1") { w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.UserSpace)) return } if strings.Contains(r.URL.RawQuery, "space-2") { w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.UserSpaceEmpty)) return } } if r.URL.Path == "/v2/users/some-user-id/spaces" { w.WriteHeader(http.StatusOK) w.Write([]byte(fixtures.UserSpaces)) return } w.WriteHeader(http.StatusTeapot) return }))
View Source
var MockUAAServer = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/check_token" { if r.Header["Authorization"][0] == "Basic dGVzdDp0ZXN0" { bodyBytes, _ := ioutil.ReadAll(r.Body) token := strings.Split(string(bodyBytes), "=")[1] if len(token) == 0 { panic("bad token") } switch token { case "valid-token": w.WriteHeader(http.StatusOK) w.Write([]byte(`{"scope":["network.admin"], "user_name":"some-user", "user_id": "some-user-id"}`)) case "space-dev-with-network-write-token": w.WriteHeader(http.StatusOK) w.Write([]byte(`{"scope":["network.write"], "user_name":"some-user", "user_id": "some-user-id"}`)) case "space-dev-token": w.WriteHeader(http.StatusOK) w.Write([]byte(`{"scope":[], "user_name":"some-user", "user_id": "some-user-id"}`)) default: w.WriteHeader(http.StatusBadRequest) w.Write([]byte(`{"error_description":"banana"}`)) } } else { w.WriteHeader(http.StatusUnauthorized) } return } if r.URL.Path == "/oauth/token" { token := ` { "access_token" : "valid-token", "token_type" : "bearer", "refresh_token" : "valid-token-r", "expires_in" : 43199, "scope" : "scim.userids openid cloud_controller.read password.write cloud_controller.write", "jti" : "9796365e7c364f41a9d2436aef6b8351" } ` if r.Header["Authorization"][0] == "Basic dGVzdDp0ZXN0" { w.WriteHeader(http.StatusOK) w.Write([]byte(token)) } else { w.WriteHeader(http.StatusUnauthorized) } return } w.WriteHeader(http.StatusNotFound) }))
Functions ¶
func DefaultTestConfig ¶
func MakeAndDoHTTPSRequest ¶
func MakeAndDoRequest ¶
func SplitUAAHostPort ¶
func StartPolicyServer ¶
func VerifyTCPConnection ¶
func WriteConfigFile ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.