@@ -58,6 +58,7 @@ import qualified Data.Text as T
5858import Data.Text.Encoding (encodeUtf8 )
5959import qualified Data.Text.IO as TIO
6060import Data.Time.Clock.System (systemToUTCTime )
61+ import qualified Database.PostgreSQL.Simple as PSQL
6162import NtfClient
6263import SMPAgentClient (agentCfg , initAgentServers , initAgentServers2 , testDB , testDB2 , testNtfServer , testNtfServer2 )
6364import SMPClient (cfgMS , cfgJ2QS , cfgVPrev , ntfTestPort , ntfTestPort2 , serverStoreConfig , testPort , testPort2 , withSmpServer , withSmpServerConfigOn , withSmpServerStoreLogOn , withSmpServerStoreMsgLogOn , xit'' )
@@ -74,6 +75,7 @@ import Simplex.Messaging.Encoding.String
7475import Simplex.Messaging.Notifications.Protocol
7576import Simplex.Messaging.Notifications.Server.Env (NtfServerConfig (.. ))
7677import Simplex.Messaging.Notifications.Server.Push.APNS
78+ import Simplex.Messaging.Notifications.Server.Store.Postgres (closeNtfDbStore , newNtfDbStore , withDB' )
7779import Simplex.Messaging.Notifications.Types (NtfTknAction (.. ), NtfToken (.. ))
7880import Simplex.Messaging.Parsers (parseAll )
7981import Simplex.Messaging.Protocol (ErrorType (AUTH ), MsgFlags (MsgFlags ), NMsgMeta (.. ), NtfServer , ProtocolServer (.. ), SMPMsgMeta (.. ), SubscriptionMode (.. ))
@@ -122,12 +124,10 @@ notificationTests ps@(t, _) = do
122124 it " should keep working with active token until replaced" $
123125 withAPNSMockServer $ \ apns ->
124126 testNtfTokenChangeServers t apns
125- -- TODO [ntfdb] modify database in the test
126- xit " should re-register token in NTInvalid status after register attempt" $
127+ it " should re-register token in NTInvalid status after register attempt" $
127128 withAPNSMockServer $ \ apns ->
128129 testNtfTokenReRegisterInvalid t apns
129- -- TODO [ntfdb] modify database in the test
130- xit " should re-register token in NTInvalid status after checking token" $
130+ it " should re-register token in NTInvalid status after checking token" $
131131 withAPNSMockServer $ \ apns ->
132132 testNtfTokenReRegisterInvalidOnCheck t apns
133133 describe " notification server tests" $ do
@@ -489,7 +489,9 @@ testNtfTokenReRegisterInvalid t apns = do
489489 withNtfServer t $ pure ()
490490
491491 threadDelay 250000
492- replaceSubstringInFile ntfTestStoreLogFile " tokenStatus=ACTIVE" " tokenStatus=INVALID"
492+ st <- newNtfDbStore ntfTestDBCfg
493+ Right 1 <- withDB' " test" st $ \ db -> PSQL. execute db " UPDATE tokens SET status = ? WHERE status = ?" (NTInvalid Nothing , NTActive )
494+ closeNtfDbStore st
493495
494496 threadDelay 250000
495497 withNtfServer t $ do
@@ -518,7 +520,9 @@ testNtfTokenReRegisterInvalidOnCheck t apns = do
518520 withNtfServer t $ pure ()
519521
520522 threadDelay 250000
521- replaceSubstringInFile ntfTestStoreLogFile " tokenStatus=ACTIVE" " tokenStatus=INVALID"
523+ st <- newNtfDbStore ntfTestDBCfg
524+ Right 1 <- withDB' " test" st $ \ db -> PSQL. execute db " UPDATE tokens SET status = ? WHERE status = ?" (NTInvalid Nothing , NTActive )
525+ closeNtfDbStore st
522526
523527 threadDelay 250000
524528 withNtfServer t $ do
0 commit comments