2 // ClaimsIdentityTest.cs - NUnit Test Cases for System.Security.Claims.ClaimsIdentity
9 using System.Collections.Generic;
11 using System.Security.Claims;
12 using System.Security.Principal;
14 namespace MonoTests.System.Security.Claims
17 public class ClaimsIdentityTest
22 public void EmptyCtorWorks ()
24 var id = new ClaimsIdentity ();
25 Assert.IsNull (id.AuthenticationType, "#1");
26 Assert.IsNull (id.Actor, "#2");
27 Assert.IsNull (id.BootstrapContext, "#3");
28 Assert.IsNotNull (id.Claims, "#4");
29 Assert.AreEqual (0, id.Claims.Count (), "#5");
30 Assert.IsFalse (id.IsAuthenticated, "#6");
31 Assert.IsNull (id.Label, "#7");
32 Assert.IsNull (id.Name, "#8");
33 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
34 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
39 #region Ctor AuthTypeOnly
42 public void AuthTypeOnlyCtorEmptyWorks ()
44 var id = new ClaimsIdentity ("");
45 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
46 //Assert.IsNull (id.AuthenticationType, "#1");
47 Assert.AreEqual ("", id.AuthenticationType, "#1");
48 Assert.IsNull (id.Actor, "#2");
49 Assert.IsNull (id.BootstrapContext, "#3");
50 Assert.IsNotNull (id.Claims, "#4");
51 Assert.AreEqual (0, id.Claims.Count (), "#5");
52 Assert.IsFalse (id.IsAuthenticated, "#6");
53 Assert.IsNull (id.Label, "#7");
54 Assert.IsNull (id.Name, "#8");
55 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
56 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
60 public void AuthTypeOnlyCtorNullWorks ()
62 var id = new ClaimsIdentity ((string)null);
63 Assert.IsNull (id.AuthenticationType, "#1");
64 Assert.IsNull (id.Actor, "#2");
65 Assert.IsNull (id.BootstrapContext, "#3");
66 Assert.IsNotNull (id.Claims, "#4");
67 Assert.AreEqual (0, id.Claims.Count (), "#5");
68 Assert.IsFalse (id.IsAuthenticated, "#6");
69 Assert.IsNull (id.Label, "#7");
70 Assert.IsNull (id.Name, "#8");
71 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
72 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
76 public void AuthTypeOnlyCtorNotEmptyWorks ()
78 var id = new ClaimsIdentity ("auth_type");
79 Assert.AreEqual ("auth_type", id.AuthenticationType, "#1");
80 Assert.IsNull (id.Actor, "#2");
81 Assert.IsNull (id.BootstrapContext, "#3");
82 Assert.IsNotNull (id.Claims, "#4");
83 Assert.AreEqual (0, id.Claims.Count (), "#5");
84 Assert.IsTrue (id.IsAuthenticated, "#6");
85 Assert.IsNull (id.Label, "#7");
86 Assert.IsNull (id.Name, "#8");
87 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
88 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
93 #region Ctor IEnumerable<Claim>
96 public void EnumClaimsCtorNullWorks ()
98 var id = new ClaimsIdentity ((IEnumerable<Claim>)null);
99 Assert.IsNull (id.AuthenticationType, "#1");
100 Assert.IsNull (id.Actor, "#2");
101 Assert.IsNull (id.BootstrapContext, "#3");
102 Assert.IsNotNull (id.Claims, "#4");
103 Assert.AreEqual (0, id.Claims.Count (), "#5");
104 Assert.IsFalse (id.IsAuthenticated, "#6");
105 Assert.IsNull (id.Label, "#7");
106 Assert.IsNull (id.Name, "#8");
107 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
108 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
112 public void EnumClaimsCtorEmptyWorks ()
114 var id = new ClaimsIdentity ((IEnumerable<Claim>)null);
115 Assert.IsNull (id.AuthenticationType, "#1");
116 Assert.IsNull (id.Actor, "#2");
117 Assert.IsNull (id.BootstrapContext, "#3");
118 Assert.IsNotNull (id.Claims, "#4");
119 Assert.AreEqual (0, id.Claims.Count (), "#5");
120 Assert.IsFalse (id.IsAuthenticated, "#6");
121 Assert.IsNull (id.Label, "#7");
122 Assert.IsNull (id.Name, "#8");
123 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
124 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
128 public void EnumClaimsCtorWithClaimsWithNameWorks ()
130 var id = new ClaimsIdentity (
132 new Claim ("claim_type", "claim_value"),
133 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
135 Assert.IsNull (id.AuthenticationType, "#1");
136 Assert.IsNull (id.Actor, "#2");
137 Assert.IsNull (id.BootstrapContext, "#3");
138 Assert.IsNotNull (id.Claims, "#4");
139 Assert.AreEqual (2, id.Claims.Count (), "#5");
140 Assert.IsFalse (id.IsAuthenticated, "#6");
141 Assert.IsNull (id.Label, "#7");
142 Assert.AreEqual ("claim_name_value", id.Name, "#8");
143 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
144 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
148 public void EnumClaimsCtorWithClaimsWithoutNameWorks ()
150 var id = new ClaimsIdentity (
152 new Claim ("claim_type", "claim_value"),
153 new Claim (ClaimsIdentity.DefaultNameClaimType + "_x", "claim_name_value"),
155 Assert.IsNull (id.AuthenticationType, "#1");
156 Assert.IsNull (id.Actor, "#2");
157 Assert.IsNull (id.BootstrapContext, "#3");
158 Assert.IsNotNull (id.Claims, "#4");
159 Assert.AreEqual (2, id.Claims.Count (), "#5");
160 Assert.IsFalse (id.IsAuthenticated, "#6");
161 Assert.IsNull (id.Label, "#7");
162 Assert.IsNull (id.Name, "#8");
163 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
164 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
169 #region Ctor IEnumerable<Claim>, authType, nameType, roleType
172 public void EnumClaimsAuthNameRoleTypeCtorWorks ()
174 var id = new ClaimsIdentity (new [] {
175 new Claim ("claim_type", "claim_value"),
176 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
177 new Claim ("claim_role_type", "claim_role_value"),
179 "test_auth_type", "test_name_type", "claim_role_type");
180 Assert.AreEqual ("test_auth_type", id.AuthenticationType, "#1");
181 Assert.IsNull (id.Actor, "#2");
182 Assert.IsNull (id.BootstrapContext, "#3");
183 Assert.IsNotNull (id.Claims, "#4");
184 Assert.AreEqual (3, id.Claims.Count (), "#5");
185 Assert.IsTrue (id.IsAuthenticated, "#6");
186 Assert.IsNull (id.Label, "#7");
187 Assert.IsNull (id.Name, "#8");
188 Assert.AreEqual ("test_name_type", id.NameClaimType, "#9");
189 Assert.AreEqual ("claim_role_type", id.RoleClaimType, "#10");
193 public void EnumClaimsAuthNameRoleTypeCtorAllArgsNullWorks ()
195 var id = new ClaimsIdentity ((IEnumerable<Claim>)null, (string)null, (string)null, (string)null);
196 Assert.IsNull (id.AuthenticationType, "#1");
197 Assert.IsNull (id.Actor, "#2");
198 Assert.IsNull (id.BootstrapContext, "#3");
199 Assert.IsNotNull (id.Claims, "#4");
200 Assert.AreEqual (0, id.Claims.Count (), "#5");
201 Assert.IsFalse (id.IsAuthenticated, "#6");
202 Assert.IsNull (id.Label, "#7");
203 Assert.IsNull (id.Name, "#8");
204 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
205 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
209 public void EnumClaimsAuthNameRoleTypeCtorAllArgsEmptyWorks ()
211 var id = new ClaimsIdentity (new Claim [0], "", "", "");
212 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
213 //Assert.IsNull (id.AuthenticationType, "#1");
214 Assert.AreEqual ("", id.AuthenticationType, "#1");
215 Assert.IsNull (id.Actor, "#2");
216 Assert.IsNull (id.BootstrapContext, "#3");
217 Assert.IsNotNull (id.Claims, "#4");
218 Assert.AreEqual (0, id.Claims.Count (), "#5");
219 Assert.IsFalse (id.IsAuthenticated, "#6");
220 Assert.IsNull (id.Label, "#7");
221 Assert.IsNull (id.Name, "#8");
222 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
223 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
227 public void EnumClaimsAuthNameRoleTypeCtorWithTwoClaimsAndTypesEmptyWorks ()
229 var id = new ClaimsIdentity (
231 new Claim ("claim_type", "claim_value"),
232 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
235 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
236 //Assert.IsNull (id.AuthenticationType, "#1");
237 Assert.AreEqual ("", id.AuthenticationType, "#1");
238 Assert.IsNull (id.Actor, "#2");
239 Assert.IsNull (id.BootstrapContext, "#3");
240 Assert.IsNotNull (id.Claims, "#4");
241 Assert.AreEqual (2, id.Claims.Count (), "#5");
242 Assert.IsFalse (id.IsAuthenticated, "#6");
243 Assert.IsNull (id.Label, "#7");
244 Assert.AreEqual ("claim_name_value", id.Name, "#8");
245 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
246 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
250 public void EnumClaimsAuthNameRoleTypeCtorWithTwoClaimsAndTypesNullWorks ()
252 var id = new ClaimsIdentity (
254 new Claim ("claim_type", "claim_value"),
255 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
257 (string)null, (string)null, (string)null);
258 Assert.IsNull (id.AuthenticationType, "#1");
259 Assert.IsNull (id.Actor, "#2");
260 Assert.IsNull (id.BootstrapContext, "#3");
261 Assert.IsNotNull (id.Claims, "#4");
262 Assert.AreEqual (2, id.Claims.Count (), "#5");
263 Assert.IsFalse (id.IsAuthenticated, "#6");
264 Assert.IsNull (id.Label, "#7");
265 Assert.AreEqual ("claim_name_value", id.Name, "#8");
266 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
267 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
272 #region Ctor IIdentity, IEnumerable<Claim>, authType, nameType, roleType
275 public void IdentityEnumClaimsAuthNameRoleTypeCtorNullsWorks ()
277 var id = new ClaimsIdentity ((IIdentity)null, (IEnumerable<Claim>)null, (string)null, (string)null, (string)null);
278 Assert.IsNull (id.AuthenticationType, "#1");
279 Assert.IsNull (id.Actor, "#2");
280 Assert.IsNull (id.BootstrapContext, "#3");
281 Assert.IsNotNull (id.Claims, "#4");
282 Assert.AreEqual (0, id.Claims.Count (), "#5");
283 Assert.IsFalse (id.IsAuthenticated, "#6");
284 Assert.IsNull (id.Label, "#7");
285 Assert.IsNull (id.Name, "#8");
286 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
287 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
291 public void IdentityEnumClaimsAuthNameRoleTypeCtorIdentityNullRestEmptyWorks ()
293 var id = new ClaimsIdentity (null, new Claim [0], "", "", "");
294 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
295 //Assert.IsNull (id.AuthenticationType, "#1");
296 Assert.AreEqual ("", id.AuthenticationType, "#1");
297 Assert.IsNull (id.Actor, "#2");
298 Assert.IsNull (id.BootstrapContext, "#3");
299 Assert.IsNotNull (id.Claims, "#4");
300 Assert.AreEqual (0, id.Claims.Count (), "#5");
301 Assert.IsFalse (id.IsAuthenticated, "#6");
302 Assert.IsNull (id.Label, "#7");
303 Assert.IsNull (id.Name, "#8");
304 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
305 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
309 public void IdentityEnumClaimsAuthNameRoleTypeCtorNullClaimsArrayEmptyTypesWorks ()
311 var id = new ClaimsIdentity (
314 new Claim ("claim_type", "claim_value"),
315 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
318 //NOTE: According to MSDN the id.AuthenticationType should be null, but it isn't on .Net 4.5
319 //Assert.IsNull (id.AuthenticationType, "#1");
320 Assert.AreEqual ("", id.AuthenticationType, "#1");
321 Assert.IsNull (id.Actor, "#2");
322 Assert.IsNull (id.BootstrapContext, "#3");
323 Assert.IsNotNull (id.Claims, "#4");
324 Assert.AreEqual (2, id.Claims.Count (), "#5");
325 Assert.IsFalse (id.IsAuthenticated, "#6");
326 Assert.IsNull (id.Label, "#7");
327 Assert.AreEqual ("claim_name_value", id.Name, "#8");
328 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
329 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
333 public void IdentityEnumClaimsAuthNameRoleTypeCtorNullClaimsArrayNullsWorks ()
335 var id = new ClaimsIdentity (
338 new Claim ("claim_type", "claim_value"),
339 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
341 (string)null, (string)null, (string)null);
342 Assert.IsNull (id.AuthenticationType, "#1");
343 Assert.IsNull (id.Actor, "#2");
344 Assert.IsNull (id.BootstrapContext, "#3");
345 Assert.IsNotNull (id.Claims, "#4");
346 Assert.AreEqual (2, id.Claims.Count (), "#5");
347 Assert.IsFalse (id.IsAuthenticated, "#6");
348 Assert.IsNull (id.Label, "#7");
349 Assert.AreEqual ("claim_name_value", id.Name, "#8");
350 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
351 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
355 public void IdentityEnumClaimsAuthNameRoleTypeCtorNullIdentityRestFilledWorks ()
357 var id = new ClaimsIdentity (
360 new Claim ("claim_type", "claim_value"),
361 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
362 new Claim ("claim_role_type", "claim_role_value"),
364 "test_auth_type", "test_name_type", "claim_role_type");
365 Assert.AreEqual ("test_auth_type", id.AuthenticationType, "#1");
366 Assert.IsNull (id.Actor, "#2");
367 Assert.IsNull (id.BootstrapContext, "#3");
368 Assert.IsNotNull (id.Claims, "#4");
369 Assert.AreEqual (3, id.Claims.Count (), "#5");
370 Assert.IsTrue (id.IsAuthenticated, "#6");
371 Assert.IsNull (id.Label, "#7");
372 Assert.IsNull (id.Name, "#8");
373 Assert.AreEqual ("test_name_type", id.NameClaimType, "#9");
374 Assert.AreEqual ("claim_role_type", id.RoleClaimType, "#10");
378 public void IdentityEnumClaimsAuthNameRoleTypeCtorClaimsIdentityRestFilledWorks ()
380 var baseId = new ClaimsIdentity (
381 new[] { new Claim ("base_claim_type", "base_claim_value") },
384 baseId.Actor = new ClaimsIdentity ("base_actor");
385 baseId.BootstrapContext = "bootstrap_context";
386 baseId.Label = "base_label";
388 Assert.IsTrue (baseId.IsAuthenticated, "#0");
390 var id = new ClaimsIdentity (
393 new Claim ("claim_type", "claim_value"),
394 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
395 new Claim ("claim_role_type", "claim_role_value"),
397 "test_auth_type", "test_name_type", "claim_role_type");
399 Assert.AreEqual ("test_auth_type", id.AuthenticationType, "#1");
401 Assert.IsNotNull (id.Actor, "#2");
402 Assert.AreEqual ("base_actor", id.Actor.AuthenticationType, "#2b");
403 Assert.AreEqual ("bootstrap_context", id.BootstrapContext, "#3");
404 Assert.IsNotNull (id.Claims, "#4");
405 Assert.AreEqual (4, id.Claims.Count (), "#5");
406 Assert.AreEqual ("base_claim_type", id.Claims.First ().Type);
407 Assert.IsTrue (id.IsAuthenticated, "#6");
408 Assert.AreEqual ("base_label", id.Label, "#7");
409 Assert.IsNull (id.Name, "#8");
410 Assert.AreEqual ("test_name_type", id.NameClaimType, "#9");
411 Assert.AreEqual ("claim_role_type", id.RoleClaimType, "#10");
415 public void IdentityEnumClaimsAuthNameRoleTypeCtorNonClaimsIdentityRestEmptyWorks ()
417 var baseId = new TestIdentity { Name = "base_name", AuthenticationType = "TestId_AuthType" };
419 var id = new ClaimsIdentity (
422 new Claim ("claim_type", "claim_value"),
423 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
424 new Claim ("claim_role_type", "claim_role_value"),
428 Assert.AreEqual ("TestId_AuthType", id.AuthenticationType, "#1");
430 Assert.IsNull (id.Actor, "#2");
431 Assert.IsNull (id.BootstrapContext, "#3");
432 Assert.IsNotNull (id.Claims, "#4");
433 Assert.AreEqual (4, id.Claims.Count (), "#5");
434 Assert.AreEqual (2, id.Claims.Count (_ => _.Type == ClaimsIdentity.DefaultNameClaimType), "#5b");
435 Assert.IsTrue (id.IsAuthenticated, "#6");
436 Assert.IsNull (id.Label, "#7");
437 Assert.AreEqual ("base_name", id.Name, "#8");
438 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
439 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
444 #region Ctor IIdentity, IEnumerable<Claim>
447 public void IdentityEnumClaimsCtorClaimsIdentityClaimsWorks ()
449 var baseId = new ClaimsIdentity (
450 new [] { new Claim ("base_claim_type", "base_claim_value") },
451 "base_auth_type", "base_name_claim_type", null);
453 baseId.Actor = new ClaimsIdentity ("base_actor");
454 baseId.BootstrapContext = "bootstrap_context";
455 baseId.Label = "base_label";
457 Assert.IsTrue (baseId.IsAuthenticated, "#0");
459 var id = new ClaimsIdentity (
462 new Claim ("claim_type", "claim_value"),
463 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
464 new Claim ("claim_role_type", "claim_role_value"),
467 Assert.AreEqual ("base_auth_type", id.AuthenticationType, "#1");
469 Assert.IsNotNull (id.Actor, "#2");
470 Assert.AreEqual ("base_actor", id.Actor.AuthenticationType, "#2b");
471 Assert.AreEqual ("bootstrap_context", id.BootstrapContext, "#3");
472 Assert.IsNotNull (id.Claims, "#4");
473 Assert.AreEqual (4, id.Claims.Count (), "#5");
474 Assert.AreEqual ("base_claim_type", id.Claims.First ().Type, "#5b");
475 Assert.IsTrue (id.IsAuthenticated, "#6");
476 Assert.AreEqual ("base_label", id.Label, "#7");
477 Assert.IsNull (id.Name, "#8");
478 Assert.AreEqual ("base_name_claim_type", id.NameClaimType, "#9");
479 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
483 public void IdentityEnumClaimsCtorNonClaimsIdentityClaimsWorks ()
485 var baseId = new TestIdentity {
486 Name = "base_name", AuthenticationType = "TestId_AuthType"
489 var id = new ClaimsIdentity (
492 new Claim ("claim_type", "claim_value"),
493 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
494 new Claim ("claim_role_type", "claim_role_value"),
497 Assert.AreEqual ("TestId_AuthType", id.AuthenticationType, "#1");
499 Assert.IsNull (id.Actor, "#2");
500 Assert.IsNull (id.BootstrapContext, "#3");
501 Assert.IsNotNull (id.Claims, "#4");
502 Assert.AreEqual (4, id.Claims.Count (), "#5");
503 Assert.AreEqual (2, id.Claims.Count (_ => _.Type == ClaimsIdentity.DefaultNameClaimType), "#5b");
504 Assert.IsTrue (id.IsAuthenticated, "#6");
505 Assert.IsNull (id.Label, "#7");
506 Assert.AreEqual ("base_name", id.Name, "#8");
507 Assert.AreEqual (ClaimsIdentity.DefaultNameClaimType, id.NameClaimType, "#9");
508 Assert.AreEqual (ClaimsIdentity.DefaultRoleClaimType, id.RoleClaimType, "#10");
514 public void FindCaseInsensivity ()
516 var claim_type = new Claim("TYpe", "value");
517 var id = new ClaimsIdentity (
518 new[] { claim_type },
519 "base_auth_type", "base_name_claim_type", null);
521 var f1 = id.FindFirst ("tyPe");
522 Assert.AreEqual ("value", f1.Value, "#1");
524 var f2 = id.FindAll ("tyPE").First ();
525 Assert.AreEqual ("value", f2.Value, "#2");
529 public void HasClaim_typeValue_Works()
531 var id = new ClaimsIdentity(
533 new Claim ("claim_type", "claim_value"),
534 new Claim (ClaimsIdentity.DefaultNameClaimType, "claim_name_value"),
535 new Claim ("claim_role_type", "claim_role_value"),
536 }, "test_authority");
538 Assert.IsTrue (id.HasClaim("claim_type", "claim_value"), "#1");
539 Assert.IsTrue (id.HasClaim("cLaIm_TyPe", "claim_value"), "#2");
540 Assert.IsFalse (id.HasClaim("claim_type", "cLaIm_VaLuE"), "#3");
541 Assert.IsFalse (id.HasClaim("Xclaim_type", "claim_value"), "#4");
542 Assert.IsFalse (id.HasClaim("claim_type", "Xclaim_value"), "#5");
546 class TestIdentity : IIdentity
553 public string AuthenticationType {
558 public bool IsAuthenticated {
559 get { throw new NotImplementedException (); }