فهرست منبع

remove TestAuthService_RegisterBOSSession_SessionNotFound

SessionManager.AddSession no longer returns a nil value. Remove the unit
test that checks for this behavior.
Mike 2 سال پیش
والد
کامیت
52417518b3
2فایلهای تغییر یافته به همراه3 افزوده شده و 28 حذف شده
  1. 0 27
      foodgroup/auth_test.go
  2. 3 1
      state/session_manager.go

+ 0 - 27
foodgroup/auth_test.go

@@ -991,33 +991,6 @@ func TestAuthService_RegisterBOSSession_HappyPath(t *testing.T) {
 	assert.Equal(t, sess, have)
 }
 
-func TestAuthService_RegisterBOSSession_SessionNotFound(t *testing.T) {
-	sess := newTestSession("screen-name")
-
-	sessionManager := newMockSessionManager(t)
-	sessionManager.EXPECT().
-		AddSession(sess.DisplayScreenName()).
-		Return(nil)
-
-	authCookie := []byte(`the-auth-cookie`)
-	cookieBaker := newMockCookieBaker(t)
-
-	cookieBaker.EXPECT().
-		Crack(authCookie).
-		Return([]byte("screen-name"), nil)
-
-	userManager := newMockUserManager(t)
-	userManager.EXPECT().
-		User(sess.IdentScreenName()).
-		Return(&state.User{DisplayScreenName: sess.DisplayScreenName()}, nil)
-
-	svc := NewAuthService(config.Config{}, sessionManager, nil, userManager, nil, cookieBaker, nil, nil, nil)
-
-	have, err := svc.RegisterBOSSession(authCookie)
-	assert.NoError(t, err)
-	assert.Nil(t, have)
-}
-
 func TestAuthService_RetrieveBOSSession_HappyPath(t *testing.T) {
 	sess := newTestSession("screen-name")
 

+ 3 - 1
state/session_manager.go

@@ -63,7 +63,9 @@ func (s *InMemorySessionManager) maybeRelayMessage(ctx context.Context, msg wire
 
 // AddSession adds a new session to the pool. It replaces an existing session
 // with a matching screen name, ensuring that each screen name is unique in the
-// pool.
+// pool. This method does not return a nil session value. It's possible to add
+// a non-existent user to the session. Callers should ensure that the account
+// represented by displayScreenName is valid.
 func (s *InMemorySessionManager) AddSession(displayScreenName DisplayScreenName) *Session {
 	s.mapMutex.Lock()
 	defer s.mapMutex.Unlock()