LoginAs logs into the CLI with 'cf auth' and the given username and password, retrying up to 3 times on failures.
(username, password string)
| 57 | // LoginAs logs into the CLI with 'cf auth' and the given username and password, |
| 58 | // retrying up to 3 times on failures. |
| 59 | func LoginAs(username, password string) { |
| 60 | env := map[string]string{ |
| 61 | "CF_USERNAME": username, |
| 62 | "CF_PASSWORD": password, |
| 63 | } |
| 64 | |
| 65 | var session *Session |
| 66 | |
| 67 | for i := 0; i < 3; i++ { |
| 68 | session = CFWithEnv(env, "auth") |
| 69 | Eventually(session).Should(Exit()) |
| 70 | if session.ExitCode() == 0 { |
| 71 | return |
| 72 | } |
| 73 | time.Sleep(3 * time.Second) |
| 74 | } |
| 75 | Expect(session.ExitCode()).To(Equal(0)) |
| 76 | } |
| 77 | |
| 78 | // LoginCF logs into the CLI using the username and password from the CF_INT_USERNAME |
| 79 | // and CF_INT_PASSWORD environment variables, respectively, defaulting to "admin" for |
no test coverage detected