replace ERROR SYNTAX 7 with ERROR SIZE for bad message body size

This commit is contained in:
Evgeny Poberezkin
2020-10-15 14:30:42 +01:00
parent bedefb11b3
commit c6b96a9cb2
4 changed files with 8 additions and 6 deletions
+5
View File
@@ -34,3 +34,8 @@ newConnection rKey =
senderKey = Nothing,
status = ConnActive
}
-- class MonadMsgStore s m where
-- addMsg :: s -> SenderId -> MsgBody -> m (Either ErrorType ())
-- getMsg :: s -> RecipientId -> m (Either ErrorType Message)
-- delMsg :: s -> RecipientId -> m (Either ErrorType ())
+1 -4
View File
@@ -123,7 +123,7 @@ type Timestamp = Encoded
type MsgBody = B.ByteString
data ErrorType = UNKNOWN | PROHIBITED | SYNTAX Int | AUTH | INTERNAL deriving (Show, Eq)
data ErrorType = UNKNOWN | PROHIBITED | SYNTAX Int | SIZE | AUTH | INTERNAL deriving (Show, Eq)
errBadParameters :: Int
errBadParameters = 2
@@ -139,6 +139,3 @@ errNoConnectionId = 5
errMessageBody :: Int
errMessageBody = 6
errMessageBodySize :: Int
errMessageBodySize = 7
+1 -1
View File
@@ -152,5 +152,5 @@ tGet fromParty h = do
Just size -> do
body <- getBytes h size
s <- getLn h
return if null s then Right body else Left $ SYNTAX errMessageBodySize
return if null s then Right body else Left SIZE
Nothing -> return . Left $ SYNTAX errMessageBody
+1 -1
View File
@@ -143,7 +143,7 @@ syntaxTests = do
it "many parameters" $ [("123", "1", "SEND 11 hello")] >#> [("", "1", "ERROR SYNTAX 2")]
it "no connection ID" $ [("123", "", "SEND :hello")] >#> [("", "", "ERROR SYNTAX 5")]
it "bad message body" $ [("123", "1", "SEND hello")] >#> [("", "1", "ERROR SYNTAX 6")]
it "bigger body" $ [("123", "1", "SEND 4\nhello\n")] >#> [("", "1", "ERROR SYNTAX 7")]
it "bigger body" $ [("123", "1", "SEND 4\nhello\n")] >#> [("", "1", "ERROR SIZE")]
describe "broker response not allowed" do
it "OK" $ [("123", "1", "OK")] >#> [("", "1", "ERROR PROHIBITED")]
where