MCPcopy Index your code
hub / github.com/cloudfoundry/cli / AddMfa

Function AddMfa

integration/helpers/fake_server.go:121–164  ·  view source on GitHub ↗

AddMfa adds a mock handler to the given server which returns a login response and a 200 status code on GET requests to the /login endpoint. It adds another mock handler to validate the given password and MFA token upon POST requests to /oauth/token.

(server *Server, password string, mfaToken string)

Source from the content-addressed store, hash-verified

119// on GET requests to the /login endpoint. It adds another mock handler to validate the given password and MFA token
120// upon POST requests to /oauth/token.
121func AddMfa(server *Server, password string, mfaToken string) {
122 getLoginResponse := fmt.Sprintf(`{
123 "app": {
124 "version": "4.28.0"
125 },
126 "showLoginLinks": true,
127 "links": {
128 "uaa": "%[1]s",
129 "passwd": "/forgot_password",
130 "login": "%[1]s",
131 "register": "/create_account"
132 },
133 "zone_name": "uaa",
134 "entityID": "some-host-name.example.com",
135 "commit_id": "8917980",
136 "idpDefinitions": {},
137 "prompts": {
138 "username": [
139 "text",
140 "Email"
141 ],
142 "password": [
143 "password",
144 "Password"
145 ],
146 "passcode": [
147 "password",
148 "Temporary Authentication Code ( Get one at %[1]s/passcode )"
149 ],
150 "mfaCode": [
151 "password",
152 "MFA Code ( Register at %[1]s )"
153 ]
154 },
155 "timestamp": "2019-02-19T18:08:02+0000"
156}`, server.URL())
157
158 server.RouteToHandler(http.MethodGet, "/login",
159 RespondWith(http.StatusOK, getLoginResponse),
160 )
161
162 server.RouteToHandler(http.MethodPost, "/oauth/token", makeMFAValidator(password, mfaToken))
163
164}
165
166func makeMFAValidator(password string, mfaToken string) http.HandlerFunc {
167 return func(res http.ResponseWriter, req *http.Request) {

Callers

nothing calls this directly

Calls 2

makeMFAValidatorFunction · 0.85
URLMethod · 0.45

Tested by

no test coverage detected