2 // ClaimsIdentityTest.cs - NUnit Test Cases for System.Security.Claims.ClaimsIdentity
8 using System.Collections.Generic;
10 using System.Security.Claims;
11 using System.Security.Principal;
13 namespace MonoTests.System.Security.Claims
16 public class ClaimsIdentityTest
21 public void EmptyCtorWorks ()
23 var id = new ClaimsIdentity ();
24 Assert.IsNull (id.AuthenticationType, "#1");
25 Assert.IsNull (id.Actor, "#2");
26 Assert.IsNull (id.BootstrapContext, "#3");
27 Assert.IsNotNull (id.Claims, "#4");
28 Assert.AreEqual (0, id.Claims.Count (), "#5");
29 Assert.IsFalse (id.IsAuthenticated, "#6");
30 Assert.IsNull (id.Label, "#7");
31 Assert.IsNull (id.Name, "#8");
32 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
33 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
38 #region Ctor AuthTypeOnly
41 public void AuthTypeOnlyCtorEmptyWorks ()
43 var id = new ClaimsIdentity ("");
44 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
45 //Assert.IsNull (id.AuthenticationType, "#1");
46 Assert.AreEqual ("", id.AuthenticationType, "#1");
47 Assert.IsNull (id.Actor, "#2");
48 Assert.IsNull (id.BootstrapContext, "#3");
49 Assert.IsNotNull (id.Claims, "#4");
50 Assert.AreEqual (0, id.Claims.Count (), "#5");
51 Assert.IsFalse (id.IsAuthenticated, "#6");
52 Assert.IsNull (id.Label, "#7");
53 Assert.IsNull (id.Name, "#8");
54 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
55 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
59 public void AuthTypeOnlyCtorNullWorks ()
61 var id = new ClaimsIdentity ((string)null);
62 Assert.IsNull (id.AuthenticationType, "#1");
63 Assert.IsNull (id.Actor, "#2");
64 Assert.IsNull (id.BootstrapContext, "#3");
65 Assert.IsNotNull (id.Claims, "#4");
66 Assert.AreEqual (0, id.Claims.Count (), "#5");
67 Assert.IsFalse (id.IsAuthenticated, "#6");
68 Assert.IsNull (id.Label, "#7");
69 Assert.IsNull (id.Name, "#8");
70 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
71 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
75 public void AuthTypeOnlyCtorNotEmptyWorks ()
77 var id = new ClaimsIdentity ("auth_type");
78 Assert.AreEqual ("auth_type", id.AuthenticationType, "#1");
79 Assert.IsNull (id.Actor, "#2");
80 Assert.IsNull (id.BootstrapContext, "#3");
81 Assert.IsNotNull (id.Claims, "#4");
82 Assert.AreEqual (0, id.Claims.Count (), "#5");
83 Assert.IsTrue (id.IsAuthenticated, "#6");
84 Assert.IsNull (id.Label, "#7");
85 Assert.IsNull (id.Name, "#8");
86 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
87 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
92 #region Ctor IEnumerable<Claim>
95 public void EnumClaimsCtorNullWorks ()
97 var id = new ClaimsIdentity ((IEnumerable<Claim>)null);
98 Assert.IsNull (id.AuthenticationType, "#1");
99 Assert.IsNull (id.Actor, "#2");
100 Assert.IsNull (id.BootstrapContext, "#3");
101 Assert.IsNotNull (id.Claims, "#4");
102 Assert.AreEqual (0, id.Claims.Count (), "#5");
103 Assert.IsFalse (id.IsAuthenticated, "#6");
104 Assert.IsNull (id.Label, "#7");
105 Assert.IsNull (id.Name, "#8");
106 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
107 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
111 public void EnumClaimsCtorEmptyWorks ()
113 var id = new ClaimsIdentity ((IEnumerable<Claim>)null);
114 Assert.IsNull (id.AuthenticationType, "#1");
115 Assert.IsNull (id.Actor, "#2");
116 Assert.IsNull (id.BootstrapContext, "#3");
117 Assert.IsNotNull (id.Claims, "#4");
118 Assert.AreEqual (0, id.Claims.Count (), "#5");
119 Assert.IsFalse (id.IsAuthenticated, "#6");
120 Assert.IsNull (id.Label, "#7");
121 Assert.IsNull (id.Name, "#8");
122 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
123 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
127 public void EnumClaimsCtorWithClaimsWithNameWorks ()
129 var id = new ClaimsIdentity (
131 new Claim ("claim_type", "claim_value"),
132 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
134 Assert.IsNull (id.AuthenticationType, "#1");
135 Assert.IsNull (id.Actor, "#2");
136 Assert.IsNull (id.BootstrapContext, "#3");
137 Assert.IsNotNull (id.Claims, "#4");
138 Assert.AreEqual (2, id.Claims.Count (), "#5");
139 Assert.IsFalse (id.IsAuthenticated, "#6");
140 Assert.IsNull (id.Label, "#7");
141 Assert.AreEqual ("claim_name_value", id.Name, "#8");
142 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
143 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
147 public void EnumClaimsCtorWithClaimsWithoutNameWorks ()
149 var id = new ClaimsIdentity (
151 new Claim ("claim_type", "claim_value"),
152 new Claim (ClaimsIdentity.DefaultNameClaimType + "_x", "claim_name_value"),
154 Assert.IsNull (id.AuthenticationType, "#1");
155 Assert.IsNull (id.Actor, "#2");
156 Assert.IsNull (id.BootstrapContext, "#3");
157 Assert.IsNotNull (id.Claims, "#4");
158 Assert.AreEqual (2, id.Claims.Count (), "#5");
159 Assert.IsFalse (id.IsAuthenticated, "#6");
160 Assert.IsNull (id.Label, "#7");
161 Assert.IsNull (id.Name, "#8");
162 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
163 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
168 #region Ctor IEnumerable<Claim>, authType, nameType, roleType
171 public void EnumClaimsAuthNameRoleTypeCtorWorks ()
173 var id = new ClaimsIdentity (new [] {
174 new Claim ("claim_type", "claim_value"),
175 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
176 new Claim ("claim_role_type", "claim_role_value"),
178 "test_auth_type", "test_name_type", "claim_role_type");
179 Assert.AreEqual ("test_auth_type", id.AuthenticationType, "#1");
180 Assert.IsNull (id.Actor, "#2");
181 Assert.IsNull (id.BootstrapContext, "#3");
182 Assert.IsNotNull (id.Claims, "#4");
183 Assert.AreEqual (3, id.Claims.Count (), "#5");
184 Assert.IsTrue (id.IsAuthenticated, "#6");
185 Assert.IsNull (id.Label, "#7");
186 Assert.IsNull (id.Name, "#8");
187 Assert.AreEqual ("test_name_type", id.NameClaimType, "#9");
188 Assert.AreEqual ("claim_role_type", id.RoleClaimType, "#10");
192 public void EnumClaimsAuthNameRoleTypeCtorAllArgsNullWorks ()
194 var id = new ClaimsIdentity ((IEnumerable<Claim>)null, (string)null, (string)null, (string)null);
195 Assert.IsNull (id.AuthenticationType, "#1");
196 Assert.IsNull (id.Actor, "#2");
197 Assert.IsNull (id.BootstrapContext, "#3");
198 Assert.IsNotNull (id.Claims, "#4");
199 Assert.AreEqual (0, id.Claims.Count (), "#5");
200 Assert.IsFalse (id.IsAuthenticated, "#6");
201 Assert.IsNull (id.Label, "#7");
202 Assert.IsNull (id.Name, "#8");
203 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
204 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
208 public void EnumClaimsAuthNameRoleTypeCtorAllArgsEmptyWorks ()
210 var id = new ClaimsIdentity (new Claim [0], "", "", "");
211 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
212 //Assert.IsNull (id.AuthenticationType, "#1");
213 Assert.AreEqual ("", id.AuthenticationType, "#1");
214 Assert.IsNull (id.Actor, "#2");
215 Assert.IsNull (id.BootstrapContext, "#3");
216 Assert.IsNotNull (id.Claims, "#4");
217 Assert.AreEqual (0, id.Claims.Count (), "#5");
218 Assert.IsFalse (id.IsAuthenticated, "#6");
219 Assert.IsNull (id.Label, "#7");
220 Assert.IsNull (id.Name, "#8");
221 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
222 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
226 public void EnumClaimsAuthNameRoleTypeCtorWithTwoClaimsAndTypesEmptyWorks ()
228 var id = new ClaimsIdentity (
230 new Claim ("claim_type", "claim_value"),
231 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
234 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
235 //Assert.IsNull (id.AuthenticationType, "#1");
236 Assert.AreEqual ("", id.AuthenticationType, "#1");
237 Assert.IsNull (id.Actor, "#2");
238 Assert.IsNull (id.BootstrapContext, "#3");
239 Assert.IsNotNull (id.Claims, "#4");
240 Assert.AreEqual (2, id.Claims.Count (), "#5");
241 Assert.IsFalse (id.IsAuthenticated, "#6");
242 Assert.IsNull (id.Label, "#7");
243 Assert.AreEqual ("claim_name_value", id.Name, "#8");
244 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
245 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
249 public void EnumClaimsAuthNameRoleTypeCtorWithTwoClaimsAndTypesNullWorks ()
251 var id = new ClaimsIdentity (
253 new Claim ("claim_type", "claim_value"),
254 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
256 (string)null, (string)null, (string)null);
257 Assert.IsNull (id.AuthenticationType, "#1");
258 Assert.IsNull (id.Actor, "#2");
259 Assert.IsNull (id.BootstrapContext, "#3");
260 Assert.IsNotNull (id.Claims, "#4");
261 Assert.AreEqual (2, id.Claims.Count (), "#5");
262 Assert.IsFalse (id.IsAuthenticated, "#6");
263 Assert.IsNull (id.Label, "#7");
264 Assert.AreEqual ("claim_name_value", id.Name, "#8");
265 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
266 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
271 #region Ctor IIdentity, IEnumerable<Claim>, authType, nameType, roleType
274 public void IdentityEnumClaimsAuthNameRoleTypeCtorNullsWorks ()
276 var id = new ClaimsIdentity ((IIdentity)null, (IEnumerable<Claim>)null, (string)null, (string)null, (string)null);
277 Assert.IsNull (id.AuthenticationType, "#1");
278 Assert.IsNull (id.Actor, "#2");
279 Assert.IsNull (id.BootstrapContext, "#3");
280 Assert.IsNotNull (id.Claims, "#4");
281 Assert.AreEqual (0, id.Claims.Count (), "#5");
282 Assert.IsFalse (id.IsAuthenticated, "#6");
283 Assert.IsNull (id.Label, "#7");
284 Assert.IsNull (id.Name, "#8");
285 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
286 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
290 public void IdentityEnumClaimsAuthNameRoleTypeCtorIdentityNullRestEmptyWorks ()
292 var id = new ClaimsIdentity (null, new Claim [0], "", "", "");
293 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
294 //Assert.IsNull (id.AuthenticationType, "#1");
295 Assert.AreEqual ("", id.AuthenticationType, "#1");
296 Assert.IsNull (id.Actor, "#2");
297 Assert.IsNull (id.BootstrapContext, "#3");
298 Assert.IsNotNull (id.Claims, "#4");
299 Assert.AreEqual (0, id.Claims.Count (), "#5");
300 Assert.IsFalse (id.IsAuthenticated, "#6");
301 Assert.IsNull (id.Label, "#7");
302 Assert.IsNull (id.Name, "#8");
303 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
304 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
308 public void IdentityEnumClaimsAuthNameRoleTypeCtorNullClaimsArrayEmptyTypesWorks ()
310 var id = new ClaimsIdentity (
313 new Claim ("claim_type", "claim_value"),
314 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
317 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
318 //Assert.IsNull (id.AuthenticationType, "#1");
319 Assert.AreEqual ("", id.AuthenticationType, "#1");
320 Assert.IsNull (id.Actor, "#2");
321 Assert.IsNull (id.BootstrapContext, "#3");
322 Assert.IsNotNull (id.Claims, "#4");
323 Assert.AreEqual (2, id.Claims.Count (), "#5");
324 Assert.IsFalse (id.IsAuthenticated, "#6");
325 Assert.IsNull (id.Label, "#7");
326 Assert.AreEqual ("claim_name_value", id.Name, "#8");
327 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
328 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
332 public void IdentityEnumClaimsAuthNameRoleTypeCtorNullClaimsArrayNullsWorks ()
334 var id = new ClaimsIdentity (
337 new Claim ("claim_type", "claim_value"),
338 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
340 (string)null, (string)null, (string)null);
341 Assert.IsNull (id.AuthenticationType, "#1");
342 Assert.IsNull (id.Actor, "#2");
343 Assert.IsNull (id.BootstrapContext, "#3");
344 Assert.IsNotNull (id.Claims, "#4");
345 Assert.AreEqual (2, id.Claims.Count (), "#5");
346 Assert.IsFalse (id.IsAuthenticated, "#6");
347 Assert.IsNull (id.Label, "#7");
348 Assert.AreEqual ("claim_name_value", id.Name, "#8");
349 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
350 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
354 public void IdentityEnumClaimsAuthNameRoleTypeCtorNullIdentityRestFilledWorks ()
356 var id = new ClaimsIdentity (
359 new Claim ("claim_type", "claim_value"),
360 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
361 new Claim ("claim_role_type", "claim_role_value"),
363 "test_auth_type", "test_name_type", "claim_role_type");
364 Assert.AreEqual ("test_auth_type", id.AuthenticationType, "#1");
365 Assert.IsNull (id.Actor, "#2");
366 Assert.IsNull (id.BootstrapContext, "#3");
367 Assert.IsNotNull (id.Claims, "#4");
368 Assert.AreEqual (3, id.Claims.Count (), "#5");
369 Assert.IsTrue (id.IsAuthenticated, "#6");
370 Assert.IsNull (id.Label, "#7");
371 Assert.IsNull (id.Name, "#8");
372 Assert.AreEqual ("test_name_type", id.NameClaimType, "#9");
373 Assert.AreEqual ("claim_role_type", id.RoleClaimType, "#10");
377 public void IdentityEnumClaimsAuthNameRoleTypeCtorClaimsIdentityRestFilledWorks ()
379 var baseId = new ClaimsIdentity (
380 new[] { new Claim ("base_claim_type", "base_claim_value") },
383 baseId.Actor = new ClaimsIdentity ("base_actor");
384 baseId.BootstrapContext = "bootstrap_context";
385 baseId.Label = "base_label";
387 Assert.IsTrue (baseId.IsAuthenticated, "#0");
389 var id = new ClaimsIdentity (
392 new Claim ("claim_type", "claim_value"),
393 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
394 new Claim ("claim_role_type", "claim_role_value"),
396 "test_auth_type", "test_name_type", "claim_role_type");
398 Assert.AreEqual ("test_auth_type", id.AuthenticationType, "#1");
400 Assert.IsNotNull (id.Actor, "#2");
401 Assert.AreEqual ("base_actor", id.Actor.AuthenticationType, "#2b");
402 Assert.AreEqual ("bootstrap_context", id.BootstrapContext, "#3");
403 Assert.IsNotNull (id.Claims, "#4");
404 Assert.AreEqual (4, id.Claims.Count (), "#5");
405 Assert.AreEqual ("base_claim_type", id.Claims.First ().Type);
406 Assert.IsTrue (id.IsAuthenticated, "#6");
407 Assert.AreEqual ("base_label", id.Label, "#7");
408 Assert.IsNull (id.Name, "#8");
409 Assert.AreEqual ("test_name_type", id.NameClaimType, "#9");
410 Assert.AreEqual ("claim_role_type", id.RoleClaimType, "#10");
414 public void IdentityEnumClaimsAuthNameRoleTypeCtorNonClaimsIdentityRestEmptyWorks ()
416 var baseId = new TestIdentity { Name = "base_name", AuthenticationType = "TestId_AuthType" };
418 var id = new ClaimsIdentity (
421 new Claim ("claim_type", "claim_value"),
422 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
423 new Claim ("claim_role_type", "claim_role_value"),
427 Assert.AreEqual ("TestId_AuthType", id.AuthenticationType, "#1");
429 Assert.IsNull (id.Actor, "#2");
430 Assert.IsNull (id.BootstrapContext, "#3");
431 Assert.IsNotNull (id.Claims, "#4");
432 Assert.AreEqual (4, id.Claims.Count (), "#5");
433 Assert.AreEqual (2, id.Claims.Count (_ => _.Type == ClaimsIdentity.DefaultNameClaimType), "#5b");
434 Assert.IsTrue (id.IsAuthenticated, "#6");
435 Assert.IsNull (id.Label, "#7");
436 Assert.AreEqual ("base_name", id.Name, "#8");
437 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
438 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
443 #region Ctor IIdentity, IEnumerable<Claim>
446 public void IdentityEnumClaimsCtorClaimsIdentityClaimsWorks ()
448 var baseId = new ClaimsIdentity (
449 new [] { new Claim ("base_claim_type", "base_claim_value") },
450 "base_auth_type", "base_name_claim_type", null);
452 baseId.Actor = new ClaimsIdentity ("base_actor");
453 baseId.BootstrapContext = "bootstrap_context";
454 baseId.Label = "base_label";
456 Assert.IsTrue (baseId.IsAuthenticated, "#0");
458 var id = new ClaimsIdentity (
461 new Claim ("claim_type", "claim_value"),
462 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
463 new Claim ("claim_role_type", "claim_role_value"),
466 Assert.AreEqual ("base_auth_type", id.AuthenticationType, "#1");
468 Assert.IsNotNull (id.Actor, "#2");
469 Assert.AreEqual ("base_actor", id.Actor.AuthenticationType, "#2b");
470 Assert.AreEqual ("bootstrap_context", id.BootstrapContext, "#3");
471 Assert.IsNotNull (id.Claims, "#4");
472 Assert.AreEqual (4, id.Claims.Count (), "#5");
473 Assert.AreEqual ("base_claim_type", id.Claims.First ().Type, "#5b");
474 Assert.IsTrue (id.IsAuthenticated, "#6");
475 Assert.AreEqual ("base_label", id.Label, "#7");
476 Assert.IsNull (id.Name, "#8");
477 Assert.AreEqual ("base_name_claim_type", id.NameClaimType, "#9");
478 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
482 public void IdentityEnumClaimsCtorNonClaimsIdentityClaimsWorks ()
484 var baseId = new TestIdentity {
485 Name = "base_name", AuthenticationType = "TestId_AuthType"
488 var id = new ClaimsIdentity (
491 new Claim ("claim_type", "claim_value"),
492 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
493 new Claim ("claim_role_type", "claim_role_value"),
496 Assert.AreEqual ("TestId_AuthType", id.AuthenticationType, "#1");
498 Assert.IsNull (id.Actor, "#2");
499 Assert.IsNull (id.BootstrapContext, "#3");
500 Assert.IsNotNull (id.Claims, "#4");
501 Assert.AreEqual (4, id.Claims.Count (), "#5");
502 Assert.AreEqual (2, id.Claims.Count (_ => _.Type == ClaimsIdentity.DefaultNameClaimType), "#5b");
503 Assert.IsTrue (id.IsAuthenticated, "#6");
504 Assert.IsNull (id.Label, "#7");
505 Assert.AreEqual ("base_name", id.Name, "#8");
506 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
507 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
513 public void FindCaseInsensivity ()
515 var claim_type = new Claim("TYpe", "value");
516 var id = new ClaimsIdentity (
517 new[] { claim_type },
518 "base_auth_type", "base_name_claim_type", null);
520 var f1 = id.FindFirst ("tyPe");
521 Assert.AreEqual ("value", f1.Value, "#1");
523 var f2 = id.FindAll ("tyPE").First ();
524 Assert.AreEqual ("value", f2.Value, "#2");
528 public void HasClaim_typeValue_Works()
530 var id = new ClaimsIdentity(
532 new Claim ("claim_type", "claim_value"),
533 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
534 new Claim ("claim_role_type", "claim_role_value"),
535 }, "test_authority");
537 Assert.IsTrue (id.HasClaim("claim_type", "claim_value"), "#1");
538 Assert.IsTrue (id.HasClaim("cLaIm_TyPe", "claim_value"), "#2");
539 Assert.IsFalse (id.HasClaim("claim_type", "cLaIm_VaLuE"), "#3");
540 Assert.IsFalse (id.HasClaim("Xclaim_type", "claim_value"), "#4");
541 Assert.IsFalse (id.HasClaim("claim_type", "Xclaim_value"), "#5");
545 class TestIdentity : IIdentity
552 public string AuthenticationType {
557 public bool IsAuthenticated {
558 get { throw new NotImplementedException (); }