()
| 27 | test_password = "12345678" |
| 28 | |
| 29 | def FetchSessionId(): |
| 30 | logging.info("Getting initial cookie to login ...") |
| 31 | |
| 32 | conn = http.client.HTTPSConnection(osmHost) |
| 33 | conn.request("GET", "/login?cookie_test=true") |
| 34 | res = conn.getresponse() |
| 35 | |
| 36 | cookies = SimpleCookie() |
| 37 | cookies.load(res.headers['Set-Cookie']) |
| 38 | |
| 39 | authToken = FindAuthenticityToken("/login", res.read().decode("utf-8")) |
| 40 | |
| 41 | if authToken is None: |
| 42 | raise Exception("Can't find 'authenticity_token'") |
| 43 | |
| 44 | logging.info(f"Parsed authToken = {authToken}") |
| 45 | logging.info("Got cookies: %s",res.headers['Set-Cookie']) |
| 46 | |
| 47 | return cookies, authToken |
| 48 | |
| 49 | def LoginUserPassword(username, password, cookies, authToken): |
| 50 | logging.info("Logging in with username and password ...") |
no test coverage detected