summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/news/test/unit/test_nntpPassword.js
blob: dbccf01f740b44d976b9e10724f9120acf4b01cf (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
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/**
 * Authentication tests for NNTP (based on RFC4643).
 *
 * Note: Logins for newsgroup servers for 1.8 were stored with either the
 * default port or the SSL default port. Nothing else!
 */

/* import-globals-from ../../../test/resources/passwordStorage.js */
load("../../../resources/passwordStorage.js");

// The basic daemon to use for testing Nntpd.jsm implementations
var daemon = setupNNTPDaemon();

add_task(async function () {
  // Prepare files for passwords (generated by a script in bug 1018624).
  await setupForPassword("signons-mailnews1.8.json");

  var server = makeServer(NNTP_RFC4643_extension, daemon);
  server.start();

  try {
    var prefix = "news://localhost:" + server.port + "/";
    var transaction;

    // Test - group subscribe listing
    test = "news:*";
    setupProtocolTest(server.port, prefix + "*");
    server.performTest();
    transaction = server.playTransaction();
    do_check_transaction(transaction, [
      "MODE READER",
      "LIST",
      "AUTHINFO user testnews",
      "AUTHINFO pass newstest",
      "LIST",
    ]);
  } catch (e) {
    dump("NNTP Protocol test " + test + " failed for type RFC 977:\n");
    try {
      var trans = server.playTransaction();
      if (trans) {
        dump("Commands called: " + trans.them + "\n");
      }
    } catch (exp) {}
    do_throw(e);
  }
  server.stop();

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