summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/imap/test/unit/test_imapClientid.js
blob: bceb7c05bff961debaf68c8f1b5d1174fe3d7977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

var { MailServices } = ChromeUtils.import(
  "resource:///modules/MailServices.jsm"
);

var incomingServer, server;

const kUserName = "user";
const kValidPassword = "password";

var gTests = [
  {
    title: "Cleartext password, with server only supporting old-style login",
    clientAuthMethod: Ci.nsMsgAuthMethod.passwordCleartext,
    serverAuthMethods: [],
    expectSuccess: true,
    transaction: [
      "capability",
      "CLIENTID",
      "authenticate PLAIN",
      "capability",
      "list",
      "lsub",
    ],
  },
];

add_task(async function () {
  let daemon = new ImapDaemon();
  server = makeServer(daemon, "", {
    // Make username of server match the singons.txt file
    // (pw there is intentionally invalid)
    kUsername: kUserName,
    kPassword: kValidPassword,
  });
  server.setDebugLevel(fsDebugAll);
  incomingServer = createLocalIMAPServer(server.port);

  // Turn on CLIENTID and populate the clientid with a uuid.
  incomingServer.clientidEnabled = true;
  incomingServer.clientid = "4d8776ca-0251-11ea-8d71-362b9e155667";

  // Connect.
  incomingServer.performExpand(null);
  server.performTest("LSUB");

  do_check_transaction(server.playTransaction(), gTests[0].transaction, false);

  server.resetTest();
});

registerCleanupFunction(function () {
  incomingServer.closeCachedConnections();
  server.stop();

  var thread = gThreadManager.currentThread;
  while (thread.hasPendingEvents()) {
    thread.processNextEvent(true);
  }
});