mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Add integration tests for signin (#2363)
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
This commit is contained in:
		
				
					committed by
					
						 Lauris BH
						Lauris BH
					
				
			
			
				
	
			
			
			
						parent
						
							fd6e91077a
						
					
				
				
					commit
					8aadf79f80
				
			| @@ -160,6 +160,13 @@ const userPassword = "password" | ||||
|  | ||||
| var loginSessionCache = make(map[string]*TestSession, 10) | ||||
|  | ||||
| func emptyTestSession(t testing.TB) *TestSession { | ||||
| 	jar, err := cookiejar.New(nil) | ||||
| 	assert.NoError(t, err) | ||||
|  | ||||
| 	return &TestSession{jar: jar} | ||||
| } | ||||
|  | ||||
| func loginUser(t testing.TB, userName string) *TestSession { | ||||
| 	if session, ok := loginSessionCache[userName]; ok { | ||||
| 		return session | ||||
| @@ -185,13 +192,13 @@ func loginUserWithPassword(t testing.TB, userName, password string) *TestSession | ||||
| 	ch.Add("Cookie", strings.Join(resp.Headers["Set-Cookie"], ";")) | ||||
| 	cr := http.Request{Header: ch} | ||||
|  | ||||
| 	jar, err := cookiejar.New(nil) | ||||
| 	assert.NoError(t, err) | ||||
| 	session := emptyTestSession(t) | ||||
|  | ||||
| 	baseURL, err := url.Parse(setting.AppURL) | ||||
| 	assert.NoError(t, err) | ||||
| 	jar.SetCookies(baseURL, cr.Cookies()) | ||||
| 	session.jar.SetCookies(baseURL, cr.Cookies()) | ||||
|  | ||||
| 	return &TestSession{jar: jar} | ||||
| 	return session | ||||
| } | ||||
|  | ||||
| type TestResponseWriter struct { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user