---
:tests:
  test_invalid_noop_response_is_ignored:
    :response: "* NOOP\r\n"
    :expected: !ruby/struct:Net::IMAP::IgnoredResponse
      name: "NOOP"
      data:
      raw_data: "* NOOP\r\n"

  test_invalid_noop_response_with_unparseable_data:
    :response: "* NOOP froopy snood\r\n"
    :expected: !ruby/struct:Net::IMAP::IgnoredResponse
      name: "NOOP"
      data: !ruby/struct:Net::IMAP::UnparsedData
        unparsed_data: "froopy snood"
      raw_data: "* NOOP froopy snood\r\n"

  test_invalid_noop_response_with_numeric_prefix:
    :response: "* 99 NOOP\r\n"
    :expected: !ruby/struct:Net::IMAP::IgnoredResponse
      name: "NOOP"
      data: 99
      raw_data: "* 99 NOOP\r\n"

  test_invalid_noop_response_with_numeric_prefix_and_unparseable_data:
    :response: "* 86 NOOP froopy snood\r\n"
    :expected: !ruby/struct:Net::IMAP::IgnoredResponse
      name: "NOOP"
      data: !ruby/struct:Net::IMAP::UnparsedNumericResponseData
        number: 86
        unparsed_data: "froopy snood"
      raw_data: "* 86 NOOP froopy snood\r\n"

  outlook.com puts an extra SP in ENVELOPE address lists:
    comment: |
      An annoying bug from outlook.com.  They've had the bug for years, and
      still have the bug as of 2023-11-28.

      The example comes from a real response, but all addresses have been
      replaced by the `faker` gem. :)
    :response: "* 24 FETCH (UID 60 INTERNALDATE \"24-May-2021 11:47:51 +0200\" RFC822.SIZE 49051 ENVELOPE (\"Mon, 24 May 20 21 09:47:50 +0000\" \"Zoooom Zoom\" ((\"Augustina Gleason\" NIL \"augustina\" \"oberbrunner.test\")) NIL NIL ((\"risa@harvey-lemke.test\" NIL \"risa\" \"harvey-lemke.test\") (\"shella@kilback-renner.test\" NIL \"shella\" \"kilback-renner.test\") (\"jana.kiehn@bradtke-considine.example\" NIL \"jana.kiehn\" \"bradtke-considine.example\") (\"frank@hartmann.test\" NIL \"frank\" \"hartmann.test\") (\"numbers.ryan@satterfield.test\" NIL \"numbers.ryan\" \"satterfield.test\") (\"keneth_feeney@will-walter.test\" NIL \"keneth_feeney\" \"will-walter.test\")) NIL NIL NIL \"<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@bbbbbbbbbbbbb.ccccccc.PROD.OUTLOOK.COM>\"))\r\n"
    :expected: !ruby/struct:Net::IMAP::UntaggedResponse
      name: FETCH
      data: !ruby/struct:Net::IMAP::FetchData
        seqno: 24
        attr:
          UID: 60
          INTERNALDATE: 24-May-2021 11:47:51 +0200
          RFC822.SIZE: 49051
          ENVELOPE: !ruby/struct:Net::IMAP::Envelope
            date: Mon, 24 May 20 21 09:47:50 +0000
            subject: Zoooom Zoom
            from:
            - !ruby/struct:Net::IMAP::Address
              name: Augustina Gleason
              route:
              mailbox: augustina
              host: oberbrunner.test
            sender:
            reply_to:
            to:
            - !ruby/struct:Net::IMAP::Address
              name: risa@harvey-lemke.test
              route:
              mailbox: risa
              host: harvey-lemke.test
            - !ruby/struct:Net::IMAP::Address
              name: shella@kilback-renner.test
              route:
              mailbox: shella
              host: kilback-renner.test
            - !ruby/struct:Net::IMAP::Address
              name: jana.kiehn@bradtke-considine.example
              route:
              mailbox: jana.kiehn
              host: bradtke-considine.example
            - !ruby/struct:Net::IMAP::Address
              name: frank@hartmann.test
              route:
              mailbox: frank
              host: hartmann.test
            - !ruby/struct:Net::IMAP::Address
              name: numbers.ryan@satterfield.test
              route:
              mailbox: numbers.ryan
              host: satterfield.test
            - !ruby/struct:Net::IMAP::Address
              name: keneth_feeney@will-walter.test
              route:
              mailbox: keneth_feeney
              host: will-walter.test
            cc:
            bcc:
            in_reply_to:
            message_id: "<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@bbbbbbbbbbbbb.ccccccc.PROD.OUTLOOK.COM>"
      raw_data: "* 24 FETCH (UID 60 INTERNALDATE \"24-May-2021 11:47:51 +0200\" RFC822.SIZE
        49051 ENVELOPE (\"Mon, 24 May 20 21 09:47:50 +0000\" \"Zoooom Zoom\" ((\"Augustina
        Gleason\" NIL \"augustina\" \"oberbrunner.test\")) NIL NIL ((\"risa@harvey-lemke.test\"
        NIL \"risa\" \"harvey-lemke.test\") (\"shella@kilback-renner.test\" NIL \"shella\"
        \"kilback-renner.test\") (\"jana.kiehn@bradtke-considine.example\" NIL \"jana.kiehn\"
        \"bradtke-considine.example\") (\"frank@hartmann.test\" NIL \"frank\" \"hartmann.test\")
        (\"numbers.ryan@satterfield.test\" NIL \"numbers.ryan\" \"satterfield.test\")
        (\"keneth_feeney@will-walter.test\" NIL \"keneth_feeney\" \"will-walter.test\"))
        NIL NIL NIL \"<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@bbbbbbbbbbbbb.ccccccc.PROD.OUTLOOK.COM>\"))\r\n"

  imap.gmail.com allows invalid atom-specials in flags:
    comment: |
      Upstream bug report: https://issuetracker.google.com/issues/315160951
      net-imap issue: https://github.com/ruby/net-imap/issues/241
    :response: "* FLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen $Forwarded $Junk
      $MailFlagBit0 $MailFlagBit2 $NotJunk $NotPhishing $Phishing Forwarded
      JunkRecorded NotJunk OIB-Seen-INBOX OIB-Seen-Unsubscribe
      OIB-Seen-[Google Mail]/Alle Nachrichten)\r\n"
    :expected: !ruby/struct:Net::IMAP::UntaggedResponse
      name: FLAGS
      data:
      - :Answered
      - :Flagged
      - :Draft
      - :Deleted
      - :Seen
      - "$Forwarded"
      - "$Junk"
      - "$MailFlagBit0"
      - "$MailFlagBit2"
      - "$NotJunk"
      - "$NotPhishing"
      - "$Phishing"
      - Forwarded
      - JunkRecorded
      - NotJunk
      - OIB-Seen-INBOX
      - OIB-Seen-Unsubscribe
      - OIB-Seen-[Google
      - Mail]/Alle
      - Nachrichten
      raw_data: "* FLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen $Forwarded
        $Junk $MailFlagBit0 $MailFlagBit2 $NotJunk $NotPhishing $Phishing Forwarded
        JunkRecorded NotJunk OIB-Seen-INBOX OIB-Seen-Unsubscribe OIB-Seen-[Google
        Mail]/Alle Nachrichten)\r\n"

  "greenmail sent \"\\*\" in a FLAGS response":
    comment: |
      net-imap issue: https://github.com/ruby/net-imap/issues/228

      Greenmail did fix their bug very quickly after it was reported. :)
      Upstream issue: https://github.com/greenmail-mail-test/greenmail/issues/633

      Also, greenmail is a testing fake server and I haven't seen any evidence
      of any "real" servers with this exact error yet. So I don't feel that it's
      critical to be compatible with it.  But, since we needed the workaround
      anyway, for #241, it's reasonable to document that it handles this too.
    :response: "* FLAGS (\\Answered \\Deleted \\Draft \\Flagged \\Seen \\*)\r\n"
    expect_rescued_error: true
    :expected: !ruby/struct:Net::IMAP::UntaggedResponse
      name: FLAGS
      data:
      - :Answered
      - :Deleted
      - :Draft
      - :Flagged
      - :Seen
      - :*
      raw_data: "* FLAGS (\\Answered \\Deleted \\Draft \\Flagged \\Seen \\*)\r\n"
