mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Remove test session cache to reduce possible concurrent problem (#22199)
This commit is contained in:
		@@ -209,8 +209,6 @@ func (s *TestSession) MakeRequestNilResponseHashSumRecorder(t testing.TB, req *h
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const userPassword = "password"
 | 
					const userPassword = "password"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var loginSessionCache = make(map[string]*TestSession, 10)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func emptyTestSession(t testing.TB) *TestSession {
 | 
					func emptyTestSession(t testing.TB) *TestSession {
 | 
				
			||||||
	t.Helper()
 | 
						t.Helper()
 | 
				
			||||||
	jar, err := cookiejar.New(nil)
 | 
						jar, err := cookiejar.New(nil)
 | 
				
			||||||
@@ -225,12 +223,8 @@ func getUserToken(t testing.TB, userName string) string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func loginUser(t testing.TB, userName string) *TestSession {
 | 
					func loginUser(t testing.TB, userName string) *TestSession {
 | 
				
			||||||
	t.Helper()
 | 
						t.Helper()
 | 
				
			||||||
	if session, ok := loginSessionCache[userName]; ok {
 | 
					
 | 
				
			||||||
		return session
 | 
						return loginUserWithPassword(t, userName, userPassword)
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	session := loginUserWithPassword(t, userName, userPassword)
 | 
					 | 
				
			||||||
	loginSessionCache[userName] = session
 | 
					 | 
				
			||||||
	return session
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func loginUserWithPassword(t testing.TB, userName, password string) *TestSession {
 | 
					func loginUserWithPassword(t testing.TB, userName, password string) *TestSession {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,4 @@ func TestSignOut(t *testing.T) {
 | 
				
			|||||||
	// try to view a private repo, should fail
 | 
						// try to view a private repo, should fail
 | 
				
			||||||
	req = NewRequest(t, "GET", "/user2/repo2")
 | 
						req = NewRequest(t, "GET", "/user2/repo2")
 | 
				
			||||||
	session.MakeRequest(t, req, http.StatusNotFound)
 | 
						session.MakeRequest(t, req, http.StatusNotFound)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	// invalidate cached cookies for user2, for subsequent tests
 | 
					 | 
				
			||||||
	delete(loginSessionCache, "user2")
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user