Ejemplo n.º 1
0
        public void AddMyCoolWebsiteRelyingPartyWithRuleGroup()
        {
            var acsNamespace = new AcsNamespace(this.namespaceDesc);

            acsNamespace.AddRelyingParty(
                rp => rp
                .Name("MyCoolWebsite")
                .RealmAddress("http://mycoolwebsite.com/")
                .ReplyAddress("http://mycoolwebsite.com/")
                .AllowGoogleIdentityProvider()
                .AllowWindowsLiveIdentityProvider()
                .RemoveRelatedRuleGroups()
                .AddRuleGroup(rg => rg.Name("Rule Group for MyCoolWebsite Relying Party")));

            acsNamespace.SaveChanges();

            Assert.IsTrue(AcsHelper.CheckRelyingPartyExists(this.namespaceDesc, "MyCoolWebsite"));
            Assert.IsTrue(AcsHelper.CheckRuleGroupExists(this.namespaceDesc, "MyCoolWebsite", "Rule Group for MyCoolWebsite Relying Party"));
        }
Ejemplo n.º 2
0
        public void AddMyCoolWebsiteRelyingPartyWithRuleGroupAndRules()
        {
            var acsNamespace = new AcsNamespace(this.namespaceDesc);

            const string MyCoolWebsite = "MyCoolWebsite";
            const string RuleGroupForMyCoolWebsiteRelyingParty = "Rule Group for MyCoolWebsite Relying Party";

            acsNamespace.AddRelyingParty(
                rp => rp
                .Name(MyCoolWebsite)
                .RealmAddress("http://mycoolwebsite.com/")
                .ReplyAddress("http://mycoolwebsite.com/")
                .AllowGoogleIdentityProvider()
                .AllowYahooIdentityProvider()
                .AllowWindowsLiveIdentityProvider()
                .RemoveRelatedRuleGroups()
                .AddRuleGroup(rg => rg
                              .Name(RuleGroupForMyCoolWebsiteRelyingParty)
                              .AddRule(
                                  rule => rule
                                  .Description("Google Passthrough")
                                  .IfInputClaimIssuer().Is("Google")
                                  .AndInputClaimType().IsOfType(ClaimTypes.Email)
                                  .AndInputClaimValue().IsAny()
                                  .ThenOutputClaimType().ShouldBe(ClaimTypes.Name)
                                  .AndOutputClaimValue().ShouldPassthroughFirstInputClaimValue())
                              .AddRule(
                                  rule => rule
                                  .Description("Yahoo! Passthrough")
                                  .IfInputClaimIssuer().Is("Yahoo!")
                                  .AndInputClaimType().IsAny()
                                  .AndInputClaimValue().IsAny()
                                  .ThenOutputClaimType().ShouldPassthroughFirstInputClaimType()
                                  .AndOutputClaimValue().ShouldPassthroughFirstInputClaimValue())
                              .AddRule(
                                  rule => rule
                                  .Description("Windows Live ID rule")
                                  .IfInputClaimIssuer().Is("Windows Live ID")
                                  .AndInputClaimType().IsOfType(ClaimTypes.Email)
                                  .AndInputClaimValue().Is("*****@*****.**")
                                  .ThenOutputClaimType().ShouldBe(ClaimTypes.NameIdentifier)
                                  .AndOutputClaimValue().ShouldBe("John Doe"))
                              .AddRule(
                                  rule => rule
                                  .Description("ACS rule")
                                  .IfInputClaimIssuer().IsAcs()
                                  .AndInputClaimType().IsAny()
                                  .AndInputClaimValue().IsAny()
                                  .ThenOutputClaimType().ShouldPassthroughFirstInputClaimType()
                                  .AndOutputClaimValue().ShouldPassthroughFirstInputClaimValue())));

            acsNamespace.SaveChanges();

            Assert.IsTrue(AcsHelper.CheckRelyingPartyExists(this.namespaceDesc, MyCoolWebsite));
            Assert.IsTrue(AcsHelper.CheckRuleGroupExists(this.namespaceDesc, MyCoolWebsite, RuleGroupForMyCoolWebsiteRelyingParty));
            Assert.IsTrue(AcsHelper.CheckRuleGroupHasRules(this.namespaceDesc, MyCoolWebsite, RuleGroupForMyCoolWebsiteRelyingParty, 4));
            Assert.IsTrue(AcsHelper.CheckRuleGroupHasRule(this.namespaceDesc, MyCoolWebsite,
                                                          RuleGroupForMyCoolWebsiteRelyingParty, "Google Passthrough"));
            Assert.IsTrue(AcsHelper.CheckRuleGroupHasRule(this.namespaceDesc, MyCoolWebsite,
                                                          RuleGroupForMyCoolWebsiteRelyingParty, "Yahoo! Passthrough"));
            Assert.IsTrue(AcsHelper.CheckRuleGroupHasRule(this.namespaceDesc, MyCoolWebsite,
                                                          RuleGroupForMyCoolWebsiteRelyingParty, "Windows Live ID rule"));
            Assert.IsTrue(AcsHelper.CheckRuleGroupHasRule(this.namespaceDesc, MyCoolWebsite,
                                                          RuleGroupForMyCoolWebsiteRelyingParty, "ACS rule"));
        }