Merge lp:~mandel/ubuntuone-windows-installer/re_enable_keyring_tests into lp:ubuntuone-windows-installer/beta

Proposed by Manuel de la Peña
Status: Merged
Approved by: Rick McBride
Approved revision: 87
Merged at revision: 89
Proposed branch: lp:~mandel/ubuntuone-windows-installer/re_enable_keyring_tests
Merge into: lp:ubuntuone-windows-installer/beta
Prerequisite: lp:~mandel/ubuntuone-windows-installer/add_env_set_up
Diff against target: 543 lines (+217/-238)
2 files modified
src/Canonical.Ubuntu.SSO.Tests/Canonical.Ubuntu.SSO.Tests.csproj (+1/-0)
src/Canonical.Ubuntu.SSO.Tests/KeyringFixture.cs (+216/-238)
To merge this branch: bzr merge lp:~mandel/ubuntuone-windows-installer/re_enable_keyring_tests
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
John Lenton (community) Approve
Review via email: mp+37575@code.launchpad.net

Description of the change

Re-enables those tests that had to be removed when the SSO calls were added. The reason for removing those tests was that they were very close to the implementation of the calls.

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Rick McBride (rmcbride) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Canonical.Ubuntu.SSO.Tests/Canonical.Ubuntu.SSO.Tests.csproj'
2--- src/Canonical.Ubuntu.SSO.Tests/Canonical.Ubuntu.SSO.Tests.csproj 2010-10-05 09:55:58 +0000
3+++ src/Canonical.Ubuntu.SSO.Tests/Canonical.Ubuntu.SSO.Tests.csproj 2010-10-05 09:55:59 +0000
4@@ -48,6 +48,7 @@
5 <Reference Include="System.Xml" />
6 </ItemGroup>
7 <ItemGroup>
8+ <Compile Include="KeyringFixture.cs" />
9 <Compile Include="Properties\AssemblyInfo.cs" />
10 </ItemGroup>
11 <ItemGroup>
12
13=== modified file 'src/Canonical.Ubuntu.SSO.Tests/KeyringFixture.cs'
14--- src/Canonical.Ubuntu.SSO.Tests/KeyringFixture.cs 2010-10-05 09:55:58 +0000
15+++ src/Canonical.Ubuntu.SSO.Tests/KeyringFixture.cs 2010-10-05 09:55:59 +0000
16@@ -20,6 +20,7 @@
17 using System.Linq;
18 using System.Security.Cryptography;
19 using System.Text;
20+using Microsoft.Win32;
21 using NUnit.Framework;
22 using Rhino.Mocks;
23
24@@ -72,262 +73,228 @@
25 }
26 }
27
28- //[TestCase("Default", "UbuntuOne", "myPassword")]
29- //[TestCase("Default", "Mandel", "Secret")]
30- //[TestCase("Test", "Leo", "MySecret")]
31- //public void CreateSecretNoRootPathPresentTest(string keyringName, string applicationName, string secret)
32- //{
33- // using (_mocks.Record())
34- // {
35- // using (_mocks.Ordered())
36- // {
37- // Expect.Call(_userRegistry.GetSubKeyNames())
38- // .Return(new[] {"Blah", "BlahBlah"})
39- // .Repeat.Twice();
40-
41- // Expect.Call(_userRegistry.CreateSubKey(Keyring.RootPath))
42- // .Return(_keyringsRoot)
43- // .Repeat.Once();
44-
45- // Expect.Call(_keyringsRoot.CreateSubKey(keyringName))
46- // .Return(_keyringKey)
47- // .Repeat.Once();
48-
49- // Expect.Call(() => _keyringKey.Dispose())
50- // .Repeat.Any();
51-
52- // Expect.Call(() => _keyringsRoot.Dispose())
53- // .Repeat.Any();
54-
55- // Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
56- // .Return(_keyringsRoot)
57- // .Repeat.Once();
58-
59- // Expect.Call(_keyringsRoot.OpenSubKey(keyringName))
60- // .Return(_keyringKey)
61- // .Repeat.Once();
62-
63- // Expect.Call(_dataProtector.Protect(secret,
64- // Encoding.UTF8.GetBytes(Keyring.Entropy), DataProtectionScope.CurrentUser))
65- // .Return(secret)
66- // .Repeat.Once();
67-
68- // Expect.Call(() => _keyringKey.SetValue(applicationName, secret))
69- // .Repeat.Once();
70-
71- // }
72-
73- // }
74- // using (_mocks.Playback())
75- // {
76- // _keyring.CreateSecret(keyringName, applicationName, secret);
77- // }
78- //}
79-
80- //[TestCase("Default", "UbuntuOne", "myPassword")]
81- //[TestCase("Default", "Mandel", "Secret")]
82- //[TestCase("Test", "Leo", "MySecret")]
83- //public void CreateSecretNoKeyringPresentTest(string keyringName, string applicationName, string secret)
84- //{
85- // using (_mocks.Record())
86- // {
87- // using(_mocks.Ordered())
88- // {
89- // Expect.Call(_userRegistry.GetSubKeyNames())
90- // .Return(new[] { "Blah", "BlahBlah", Keyring.RootPath})
91- // .Repeat.Once();
92-
93- // Expect.Call(() => _keyringsRoot.Dispose())
94- // .Repeat.Any();
95-
96- // Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
97- // .Return(_keyringsRoot)
98- // .Repeat.Once();
99-
100- // Expect.Call(_keyringsRoot.GetSubKeyNames())
101- // .Return(new string[] { })
102- // .Repeat.Once();
103-
104- // Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
105- // .Return(_keyringsRoot)
106- // .Repeat.Once();
107-
108- // Expect.Call(_keyringsRoot.CreateSubKey(keyringName))
109- // .Return(_keyringKey)
110- // .Repeat.Once();
111-
112- // Expect.Call(() => _keyringKey.Dispose())
113- // .Repeat.Any();
114-
115- // Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
116- // .Return(_keyringsRoot)
117- // .Repeat.Once();
118-
119- // Expect.Call(_keyringsRoot.OpenSubKey(keyringName))
120- // .Return(_keyringKey)
121- // .Repeat.Once();
122-
123- // Expect.Call(_dataProtector.Protect(secret,
124- // Encoding.UTF8.GetBytes(Keyring.Entropy), DataProtectionScope.CurrentUser))
125- // .Return(secret)
126- // .Repeat.Once();
127-
128- // Expect.Call(() => _keyringKey.SetValue(applicationName, secret))
129- // .Repeat.Once();
130-
131- // }
132- // }
133- // using (_mocks.Playback())
134- // {
135- // _keyring.CreateSecret(keyringName, applicationName, secret);
136- // }
137- //}
138-
139- //[TestCase("Default", "UbuntuOne", "myPassword")]
140- //[TestCase("Default", "Mandel", "Secret")]
141- //[TestCase("Test", "Leo", "MySecret")]
142- //public void CreateSecretPresentKeyringTest(string keyringName, string applicationName, string secret)
143- //{
144- // using(_mocks.Record())
145- // {
146- // using(_mocks.Ordered())
147- // {
148- // Expect.Call(_userRegistry.GetSubKeyNames())
149- // .Return(new[] { "Blah", "BlahBlah", Keyring.RootPath })
150- // .Repeat.Once();
151-
152- // Expect.Call(() => _keyringsRoot.Dispose())
153- // .Repeat.Any();
154-
155- // Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
156- // .Return(_keyringsRoot)
157- // .Repeat.Once();
158-
159- // Expect.Call(_keyringsRoot.GetSubKeyNames())
160- // .Return(new[] { keyringName})
161- // .Repeat.Once();
162-
163- // Expect.Call(() => _keyringKey.Dispose())
164- // .Repeat.Any();
165-
166- // Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
167- // .Return(_keyringsRoot)
168- // .Repeat.Once();
169-
170- // Expect.Call(_keyringsRoot.OpenSubKey(keyringName))
171- // .Return(_keyringKey)
172- // .Repeat.Once();
173-
174- // Expect.Call(_dataProtector.Protect(secret,
175- // Encoding.UTF8.GetBytes(Keyring.Entropy), DataProtectionScope.CurrentUser))
176- // .Return(secret)
177- // .Repeat.Once();
178-
179- // Expect.Call(() => _keyringKey.SetValue(applicationName, secret))
180- // .Repeat.Once();
181- // }
182- // }
183- // using(_mocks.Playback())
184- // {
185- // _keyring.CreateSecret(keyringName, applicationName, secret);
186- // }
187- //}
188+ [TestCase("Default", "UbuntuOne", "myPassword")]
189+ [TestCase("Default", "Mandel", "Secret")]
190+ [TestCase("Test", "Leo", "MySecret")]
191+ public void CreateSecretNoRootPathPresentTest(string keyringName, string applicationName, string secret)
192+ {
193+ using (_mocks.Record())
194+ {
195+ Expect.Call(_userRegistry.GetSubKeyNames())
196+ .Return(new string[0])
197+ .Repeat.Any();
198+
199+ Expect.Call(_userRegistry.CreateSubKey(Keyring.RootPath))
200+ .Return(_keyringsRoot)
201+ .Repeat.Once();
202+
203+ Expect.Call(_keyringsRoot.CreateSubKey(keyringName))
204+ .Return(_keyringKey)
205+ .Repeat.Once();
206+
207+ Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath, RegistryKeyPermissionCheck.ReadWriteSubTree))
208+ .Return(_keyringsRoot)
209+ .Repeat.Once();
210+
211+ Expect.Call(_keyringsRoot.OpenSubKey(keyringName, RegistryKeyPermissionCheck.ReadWriteSubTree))
212+ .Return(_keyringKey)
213+ .Repeat.Once();
214+
215+ Expect.Call(_dataProtector.Protect("", new byte[0], DataProtectionScope.CurrentUser))
216+ .Return(new byte[0])
217+ .IgnoreArguments()
218+ .Repeat.Once();
219+
220+ Expect.Call(() => _keyringKey.SetValue(applicationName, new byte[0]))
221+ .Repeat.Once();
222+
223+ Expect.Call(() => _keyringKey.Dispose())
224+ .Repeat.Any();
225+
226+ Expect.Call(() => _keyringsRoot.Dispose())
227+ .Repeat.Any();
228+
229+ Expect.Call(() => _userRegistry.Dispose())
230+ .Repeat.Any();
231+ }
232+ using (_mocks.Playback())
233+ {
234+ _keyring.CreateSecret(keyringName, applicationName, secret);
235+ }
236+ }
237+
238+ [TestCase("Default", "UbuntuOne", "myPassword")]
239+ [TestCase("Default", "Mandel", "Secret")]
240+ [TestCase("Test", "Leo", "MySecret")]
241+ public void CreateSecretNoKeyringPresentTest(string keyringName, string applicationName, string secret)
242+ {
243+ using (_mocks.Record())
244+ {
245+ Expect.Call(_userRegistry.GetSubKeyNames())
246+ .Return(new[] { "Blah", "BlahBlah", Keyring.RootPath })
247+ .Repeat.Any();
248+ Expect.Call(_userRegistry.CreateSubKey(Keyring.RootPath))
249+ .Return(_keyringsRoot)
250+ .Repeat.Once();
251+ Expect.Call(_keyringsRoot.CreateSubKey(keyringName))
252+ .Return(_keyringKey)
253+ .Repeat.Once();
254+ Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath, RegistryKeyPermissionCheck.ReadWriteSubTree))
255+ .Return(_keyringsRoot)
256+ .Repeat.Once();
257+ Expect.Call(_dataProtector.Protect(secret, Encoding.UTF8.GetBytes(Keyring.Entropy), DataProtectionScope.CurrentUser))
258+ .Return(new byte[0])
259+ .Repeat.Once();
260+ Expect.Call(_keyringsRoot.OpenSubKey(keyringName, RegistryKeyPermissionCheck.ReadWriteSubTree))
261+ .Return(_keyringKey)
262+ .Repeat.Once();
263+ Expect.Call(() => _keyringKey.SetValue(applicationName, new byte[0]))
264+ .Repeat.Once();
265+ Expect.Call(() => _keyringKey.Dispose())
266+ .Repeat.Any();
267+ Expect.Call(() => _keyringsRoot.Dispose())
268+ .Repeat.Any();
269+ Expect.Call(() => _userRegistry.Dispose())
270+ .Repeat.Any();
271+ }
272+ using (_mocks.Playback())
273+ {
274+ _keyring.CreateSecret(keyringName, applicationName, secret);
275+ }
276+ }
277+
278+ [TestCase("Default", "UbuntuOne", "myPassword")]
279+ [TestCase("Default", "Mandel", "Secret")]
280+ [TestCase("Test", "Leo", "MySecret")]
281+ public void CreateSecretPresentKeyringTest(string keyringName, string applicationName, string secret)
282+ {
283+ using (_mocks.Record())
284+ {
285+ Expect.Call(_userRegistry.GetSubKeyNames())
286+ .Return(new[] {"Blah", "BlahBlah", "Canonical", "Keyrings"})
287+ .Repeat.Any();
288+ Expect.Call(_userRegistry.OpenSubKey("Canonical"))
289+ .Return(_userRegistry)
290+ .Repeat.Once();
291+ Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
292+ .Return(_keyringsRoot)
293+ .Repeat.Once();
294+ Expect.Call(_keyringsRoot.GetSubKeyNames())
295+ .Return(new[] {keyringName})
296+ .Repeat.Once();
297+ Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath, RegistryKeyPermissionCheck.ReadWriteSubTree))
298+ .Return(_keyringsRoot)
299+ .Repeat.Once();
300+ Expect.Call(_keyringsRoot.OpenSubKey(keyringName, RegistryKeyPermissionCheck.ReadWriteSubTree))
301+ .Return(_keyringKey)
302+ .Repeat.Once();
303+ Expect.Call(_dataProtector.Protect(secret, Encoding.UTF8.GetBytes(Keyring.Entropy), DataProtectionScope.CurrentUser))
304+ .Return(new byte[0])
305+ .Repeat.Once();
306+ Expect.Call(() => _keyringKey.SetValue(applicationName, new byte[0]))
307+ .Repeat.Once();
308+ Expect.Call(() => _keyringKey.Dispose())
309+ .Repeat.Any();
310+ Expect.Call(() => _keyringsRoot.Dispose())
311+ .Repeat.Any();
312+ Expect.Call(() => _userRegistry.Dispose())
313+ .Repeat.Any();
314+ }
315+ using (_mocks.Playback())
316+ {
317+ _keyring.CreateSecret(keyringName, applicationName, secret);
318+ }
319+ }
320
321 [TestCase("Default", "UbuntuOne")]
322 [TestCase("Keyring", "AppNAme")]
323 public void GetSecretByNameNotKeyringTest(string keyringName, string applicationName)
324 {
325- using(_mocks.Record())
326+ using (_mocks.Record())
327 {
328 Expect.Call(_userRegistry.GetSubKeyNames())
329 .Return(new[] { "Blah", "BlahBlah" })
330 .Repeat.Once();
331 }
332- using(_mocks.Playback())
333- {
334- var secret = _keyring.GetSecretByName(keyringName, applicationName);
335- Assert.IsEmpty(secret);
336- }
337- }
338-
339- //[TestCase("Default", "UbuntuOne")]
340- //[TestCase("Keyring", "AppNAme")]
341- //public void GetSecretByNameKeyringExistsTest(string keyringName, string applicationName)
342- //{
343- // using (_mocks.Record())
344- // {
345- // using (_mocks.Ordered())
346- // {
347- // Expect.Call(_userRegistry.GetSubKeyNames())
348- // .Return(new[] { "Blah", "BlahBlah", Keyring.RootPath })
349- // .Repeat.Once();
350-
351- // Expect.Call(() => _keyringsRoot.Dispose())
352- // .Repeat.Any();
353-
354- // Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
355- // .Return(_keyringsRoot)
356- // .Repeat.Once();
357-
358- // Expect.Call(_keyringsRoot.GetSubKeyNames())
359- // .Return(new[] { keyringName })
360- // .Repeat.Once();
361-
362- // Expect.Call(() => _keyringKey.Dispose())
363- // .Repeat.Any();
364-
365- // Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
366- // .Return(_keyringsRoot)
367- // .Repeat.Once();
368-
369- // Expect.Call(_keyringsRoot.OpenSubKey(keyringName))
370- // .Return(_keyringKey)
371- // .Repeat.Once();
372-
373- // Expect.Call(_keyringKey.GetValue(applicationName))
374- // .Return(applicationName)
375- // .Repeat.Once();
376-
377- // Expect.Call(_dataProtector.Unprotect("",
378- // Encoding.UTF8.GetBytes(Keyring.Entropy), DataProtectionScope.CurrentUser))
379- // .IgnoreArguments()
380- // .Return(applicationName)
381- // .Repeat.Once();
382-
383- // }
384- // }
385- // using (_mocks.Playback())
386- // {
387- // var secret = _keyring.GetSecretByName(keyringName, applicationName);
388- // Assert.AreEqual(applicationName, secret);
389- // }
390- //}
391+ using (_mocks.Playback())
392+ {
393+ var secret = _keyring.GetSecretByName(keyringName, applicationName);
394+ Assert.IsNull(secret);
395+ }
396+ }
397+
398+ [TestCase("Default", "UbuntuOne")]
399+ [TestCase("Keyring", "AppNAme")]
400+ public void GetSecretByNameKeyringExistsTest(string keyringName, string applicationName)
401+ {
402+ using (_mocks.Record())
403+ {
404+ Expect.Call(_userRegistry.GetSubKeyNames())
405+ .Return(new[] {"Blah", "BlahBlah", "Canonical", "Keyrings"})
406+ .Repeat.Any();
407+ Expect.Call(_userRegistry.OpenSubKey("Canonical"))
408+ .Return(_userRegistry)
409+ .Repeat.Once();
410+ Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
411+ .Return(_keyringsRoot)
412+ .Repeat.Once();
413+ Expect.Call(_keyringsRoot.GetSubKeyNames())
414+ .Return(new[] {keyringName})
415+ .Repeat.Once();
416+ Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath, RegistryKeyPermissionCheck.ReadWriteSubTree))
417+ .Return(_keyringsRoot)
418+ .Repeat.Once();
419+ Expect.Call(_keyringsRoot.OpenSubKey(keyringName, RegistryKeyPermissionCheck.ReadWriteSubTree))
420+ .Return(_keyringKey)
421+ .Repeat.Once();
422+ Expect.Call(_keyringKey.GetValue(applicationName))
423+ .Return(new byte[0])
424+ .Repeat.Once();
425+ Expect.Call(_dataProtector.Unprotect(new byte[0], new byte[0], DataProtectionScope.CurrentUser))
426+ .IgnoreArguments()
427+ .Return(applicationName)
428+ .Repeat.Once();
429+ Expect.Call(() => _userRegistry.Dispose())
430+ .Repeat.Any();
431+ Expect.Call(() => _keyringsRoot.Dispose())
432+ .Repeat.Any();
433+ Expect.Call(() => _keyringKey.Dispose())
434+ .Repeat.Any();
435+ }
436+ using (_mocks.Playback())
437+ {
438+ var secret = _keyring.GetSecretByName(keyringName, applicationName);
439+ Assert.AreEqual(applicationName, secret);
440+ }
441+ }
442
443 [Test]
444 public void GetKeyringsTest()
445 {
446- var keyrings = new[] {"Default", "Test", "Test1"};
447+ var keyrings = new[] { "Default", "Test", "Test1" };
448
449- using(_mocks.Record())
450+ using (_mocks.Record())
451 {
452 // make it such that the root is present
453 Expect.Call(_userRegistry.GetSubKeyNames())
454- .Return(new[] { "Blah", "BlahBlah", Keyring.RootPath })
455- .Repeat.Once();
456-
457- Expect.Call(() => _keyringsRoot.Dispose())
458+ .Return(new[] {"Blah", "BlahBlah", "Canonical", "Keyrings"})
459 .Repeat.Any();
460-
461+ Expect.Call(_userRegistry.OpenSubKey("Canonical"))
462+ .Return(_userRegistry)
463+ .Repeat.Once();
464 Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
465 .Return(_keyringsRoot)
466 .Repeat.Once();
467-
468 Expect.Call(_keyringsRoot.GetSubKeyNames())
469 .Return(keyrings)
470 .Repeat.Once();
471+ Expect.Call(() => _userRegistry.Dispose())
472+ .Repeat.Any();
473+ Expect.Call(() => _keyringsRoot.Dispose())
474+ .Repeat.Any();
475
476 }
477- using(_mocks.Playback())
478+ using (_mocks.Playback())
479 {
480 Assert.AreSame(_keyring.GetKeyrings(), keyrings);
481 }
482@@ -340,7 +307,7 @@
483 {
484 // make it such that the root is present
485 Expect.Call(_userRegistry.GetSubKeyNames())
486- .Return(new[] { "Blah", "BlahBlah"})
487+ .Return(new[] { "Blah", "BlahBlah" })
488 .Repeat.Once();
489 }
490 using (_mocks.Playback())
491@@ -353,14 +320,19 @@
492 [TestCase("Test")]
493 public void GetApplicationsTest(string keyringName)
494 {
495- var applications = new[] {"Ubuntu One", "Test", "Default"};
496- using(_mocks.Record())
497+ var applications = new[] { "Ubuntu One", "Test", "Default" };
498+ using (_mocks.Record())
499 {
500 Expect.Call(_userRegistry.GetSubKeyNames())
501- .Return(new[] { "Blah", "BlahBlah", Keyring.RootPath })
502- .Repeat.Once();
503-
504- Expect.Call(() => _keyringsRoot.Dispose())
505+ .Return(new[] { "Blah", "BlahBlah", "Canonical", "Keyrings" })
506+ .Repeat.Any();
507+
508+ Expect.Call(_userRegistry.OpenSubKey("Canonical"))
509+ .Return(_userRegistry)
510+ .Repeat.Once();
511+
512+ Expect.Call(_userRegistry.OpenSubKey("Keyrings"))
513+ .Return(_keyringsRoot)
514 .Repeat.Any();
515
516 Expect.Call(_userRegistry.OpenSubKey(Keyring.RootPath))
517@@ -379,10 +351,16 @@
518 .Return(applications)
519 .Repeat.Once();
520
521+ Expect.Call(() => _userRegistry.Dispose())
522+ .Repeat.Any();
523+
524 Expect.Call(() => _keyringKey.Dispose())
525 .Repeat.Any();
526+
527+ Expect.Call(() => _keyringsRoot.Dispose())
528+ .Repeat.Any();
529 }
530- using(_mocks.Playback())
531+ using (_mocks.Playback())
532 {
533 Assert.AreSame(applications, _keyring.GetApplications(keyringName));
534 }
535@@ -398,7 +376,7 @@
536 .Return(new[] { "Blah", "BlahBlah" })
537 .Repeat.Once();
538 }
539- using(_mocks.Playback())
540+ using (_mocks.Playback())
541 {
542 Assert.AreEqual(0, _keyring.GetApplications("Test").Count());
543 }

Subscribers

People subscribed via source and target branches

to all changes: