summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/import/test/unit/test_winmail.js
blob: 73de9a145173e3f238092d643da4c52e8a1ee898 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**
 * Basic tests for importing accounts of Windows Live Mail.
 */

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

var expectedPop3TestTestAccount = {
  incomingServer: {
    type: "pop3",
    hostName: "pop3.test.test",
    prettyName: "testpopaccountname",
    port: 110,
    socketType: 0,
    doBiff: true,
    biffMinutes: 2,
    isSecure: false,
    username: "testpopusername",
    authMethod: Ci.nsMsgAuthMethod.passwordCleartext,
    leaveMessagesOnServer: false,
    deleteMailLeftOnServer: false,
    deleteByAgeFromServer: false,
    numDaysToLeaveOnServer: 7,
  },
  identity: {
    fullName: "popdisplayname",
    organization: "",
    email: "testpop@invalid.invalid",
  },
  smtpServer: {
    hostname: "smtp.pop.test",
    port: 0, // default port
    username: "",
    authMethod: Ci.nsMsgAuthMethod.none,
    socketType: 0,
  },
};

var expectedNewsMozillaOrgAccount = {
  incomingServer: {
    type: "nntp",
    hostName: "testnews.mozilla.org",
    prettyName: "accountnamemozillanews",
    port: 119,
    username: "",
    socketType: 0,
    isSecure: false,
    authMethod: Ci.nsMsgAuthMethod.passwordCleartext,
    doBiff: false,
    biffMinutes: 10, // default value
  },
  identity: {
    fullName: "test",
    organization: "",
    email: "mozillanews@invalid.invalid",
  },
};

var expectedMicrosoftCommunitiesAccount = {
  incomingServer: {
    type: "nntp",
    hostName: "testmsnews.microsoft.invalid",
    prettyName: "Microsoft Communities Test",
    port: 119,
    username: "",
    socketType: 0,
    isSecure: false,
    authMethod: Ci.nsMsgAuthMethod.passwordCleartext,
    doBiff: false,
    biffMinutes: 10, // default value
  },
  identity: {
    fullName: "",
    organization: "",
  },
};

var expectedDonHallNntpAccount = {
  incomingServer: {
    type: "nntp",
    hostName: "news.wingtiptoys.invalid",
    prettyName: "donhallnntp",
    port: 563,
    username: "don",
    isSecure: false,
    authMethod: Ci.nsMsgAuthMethod.secure,
    socketType: 0,
    doBiff: false,
    biffMinutes: 10, // default value
  },
  identity: {
    fullName: "Don Hall",
    organization: "Wingtip Toys",
    email: "don@wingtiptoys.invalid",
    replyTo: "don@wingtiptoys.invalid",
  },
};

var expectedDonHallImapAccount = {
  incomingServer: {
    type: "imap",
    hostName: "mail.wingtiptoys.invalid",
    prettyName: "donhallimap",
    port: 993,
    isSecure: true,
    doBiff: true,
    biffMinutes: 2,
    username: "don",
    authMethod: Ci.nsMsgAuthMethod.secure,
    socketType: Ci.nsMsgSocketType.SSL,
  },
  identity: {
    fullName: "Don Hall",
    organization: "Wingtip Toys",
    email: "don@wingtiptoys.invalid",
    replyTo: "don@wingtiptoys.invalid",
  },
  smtpServer: {
    hostname: "smtp.wingtiptoys.invalid",
    username: "don",
    port: 25,
    socketType: Ci.nsMsgSocketType.SSL,
    authMethod: Ci.nsMsgAuthMethod.secure,
  },
};

var expectedAccounts = [
  expectedPop3TestTestAccount,
  expectedNewsMozillaOrgAccount,
  expectedMicrosoftCommunitiesAccount,
  expectedDonHallNntpAccount,
  expectedDonHallImapAccount,
];

function WinLiveMailRegistry(rootPath) {
  this._rootPath = rootPath;
}

WinLiveMailRegistry.prototype = {
  get "Software\\Microsoft\\Windows Live Mail"() {
    return {
      "Default Mail Account": "fill in mail account",
      "Default News Account": "fill in news account",
      "Store Root": this._rootPath,
      mail: {
        "Poll For Mail": 120000,
      },
    };
  },
};

function _test(registry) {
  try {
    setup_mock_registry(registry);
    new SettingsImportHelper(
      null,
      "Windows Live Mail",
      expectedAccounts
    ).beginImport();
  } catch (e) {
    teardown();
    do_throw(e);
  }
  teardown();
}

function teardown() {
  for (let server of MailServices.smtp.servers) {
    MailServices.smtp.deleteServer(server);
  }

  teardown_mock_registry();
}

function run_test() {
  let root = do_get_file("resources/WindowsLiveMail");
  _test(new WinLiveMailRegistry(root.path));
}