github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/integration/helpers/fakeservicebroker/defaults.go (about) 1 package fakeservicebroker 2 3 import ( 4 "net/http" 5 6 "code.cloudfoundry.org/cli/integration/helpers" 7 ) 8 9 func defaultConfig() *FakeServiceBroker { 10 integrationNameGenerator := func() string { 11 return helpers.PrefixedRandomName("INTEGRATION-PLAN") 12 } 13 14 firstPlanName := integrationNameGenerator() 15 16 return &FakeServiceBroker{ 17 name: generateReusableBrokerName(""), 18 username: "username", 19 password: "password", 20 reusable: true, 21 domain: helpers.DefaultSharedDomain(), 22 catalogStatus: http.StatusOK, 23 Services: []service{ 24 { 25 Name: helpers.PrefixedRandomName("INTEGRATION-SERVICE"), 26 ID: helpers.RandomName(), 27 Description: helpers.PrefixedRandomName("fake service description"), 28 Bindable: true, 29 InstancesRetrievable: true, 30 BindingsRetrievable: true, 31 Metadata: metadata{ 32 Shareable: true, 33 DocumentationURL: "http://documentation.url", 34 }, 35 Requires: []string{}, 36 Plans: []plan{ 37 { 38 Name: firstPlanName, 39 ID: helpers.RandomName(), 40 Description: helpers.PrefixedRandomName("fake plan description"), 41 MaintenanceInfo: &maintenanceInfo{ 42 Version: "2.0.0", 43 Description: "OS image update.\nExpect downtime.", 44 }, 45 }, 46 { 47 Name: helpers.GenerateHigherName(integrationNameGenerator, firstPlanName), 48 ID: helpers.RandomName(), 49 Description: helpers.PrefixedRandomName("fake plan description"), 50 MaintenanceInfo: &maintenanceInfo{ 51 Version: "2.0.0", 52 Description: "OS image update.\nExpect downtime.", 53 }, 54 }, 55 }, 56 }, 57 }, 58 behaviors: behaviors{ 59 Provision: map[string]responseMock{ 60 "default": syncResponse(). 61 withBody(map[string]interface{}{ 62 "dashboard_url": "http://example.com", 63 }), 64 }, 65 Fetch: map[string]map[string]responseMock{ 66 "default": { 67 "in_progress": syncResponse(). 68 withBody(map[string]interface{}{ 69 "state": "in progress", 70 "description": "not 100 percent done", 71 }), 72 "finished": syncResponse(). 73 withBody(map[string]interface{}{ 74 "state": "succeeded", 75 "description": "100 percent done", 76 }), 77 }, 78 }, 79 Update: map[string]responseMock{ 80 "default": syncResponse(), 81 }, 82 Deprovision: map[string]responseMock{ 83 "default": syncResponse(), 84 }, 85 Bind: map[string]responseMock{ 86 "default": syncResponse(). 87 withStatus(http.StatusCreated). 88 withBody(map[string]interface{}{ 89 "credentials": map[string]interface{}{ 90 "uri": "fake-service://fake-user:fake-password@fake-host:3306/fake-dbname", 91 "username": "fake-user", 92 "password": "fake-password", 93 "host": "fake-host", 94 "port": 3306, 95 "database": "fake-dbname", 96 }, 97 }), 98 }, 99 FetchServiceBinding: map[string]responseMock{ 100 "default": syncResponse(). 101 withBody(map[string]interface{}{ 102 "credentials": map[string]interface{}{ 103 "uri": "fake-service://fake-user:fake-password@fake-host:3306/fake-dbname", 104 "username": "fake-user", 105 "password": "fake-password", 106 "host": "fake-host", 107 "port": 3306, 108 "database": "fake-dbname", 109 }, 110 }), 111 }, 112 Unbind: map[string]responseMock{ 113 "default": syncResponse(), 114 }, 115 }, 116 } 117 }