login = do
    get ("http://localhost:3000/blog" :: String)
    statusIs 200

    bodyContains "Please log in"

    action <- formActionValue "#blogLoginForm"
    liftIO $ I.unpack action `shouldStartWith` "/blog/"

    let req = do setMethod methodPost
                 setUrl $ "http://localhost:3000" ++ I.unpack action
                 byLabel "Enter the user name:" "root"
                 byLabel "Enter the password" "root"
                 addPostParam "_formid" "userForm"
                 addToken
    I.request req
    statusIs 200
    bodyContains "Blog View"
    bodyContains "You are logged in as root."

--------------------------  Blog view page  --------------------------
login = do
    get ("http://localhost:3000/blog" :: String)
    statusIs 200

    bodyContains "Please log in"

    action <- formActionValue "#blogLoginForm"
    liftIO $ I.unpack action `shouldStartWith` "/blog/"

    let req = do setMethod methodPost
                 setUrl $ "http://localhost:3000" ++ I.unpack action
                 byLabel "Enter the user name:" "root"
                 byLabel "Enter the password" "root"
                 addPostParam "_formid" "userForm"
                 addToken
    I.request req
    statusIs 200
    bodyContains "Blog View"
    bodyContains "You are logged in as root."

--------------------------  Blog view page  --------------------------
login = do
    get ("http://localhost:3000/blog" :: String)
    statusIs 200

    bodyContains "Please log in"

    action <- formActionValue "#blogLoginForm"
    liftIO $ I.unpack action `shouldStartWith` "/blog/"

    let req = do setMethod methodPost
                 setUrl $ "http://localhost:3000" ++ I.unpack action
                 byLabel "Enter the user name:" "root"
                 byLabel "Enter the password" "root"
                 addPostParam "_formid" "userForm"
                 addToken
    I.request req
    statusIs 200
    bodyContains "Blog View"
    bodyContains "You are logged in as root."

--------------------------  Blog view page  --------------------------