private async Task ParameterizedAXTestAsync(AXAttributeFormats format)
        {
            var axInjected = new FetchRequest();

            axInjected.Attributes.AddOptional(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, format));
            axInjected.Attributes.AddRequired(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.FullName, format));
            this.extensions.Add(axInjected);
            var sreg = ExtensionsInteropHelper.UnifyExtensionsAsSreg(this.request);

            Assert.AreSame(sreg, this.request.GetExtension <ClaimsRequest>());
            Assert.AreEqual(DemandLevel.Request, sreg.Nickname);
            Assert.AreEqual(DemandLevel.Require, sreg.FullName);
            Assert.AreEqual(DemandLevel.NoRequest, sreg.Language);

            var sregResponse = sreg.CreateResponse();

            sregResponse.Nickname = "andy";
            this.request.AddResponseExtension(sregResponse);
            await ExtensionsInteropHelper.ConvertSregToMatchRequestAsync(this.request, CancellationToken.None);

            var extensions = await this.GetResponseExtensionsAsync();

            var axResponse = extensions.OfType <FetchResponse>().Single();

            Assert.AreEqual("andy", axResponse.GetAttributeValue(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, format)));
        }
Example #2
0
        public void UnifyExtensionsasSregFromSchemaOpenIdNet()
        {
            var axInjected = new FetchResponse();

            axInjected.Attributes.Add(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet), "nate");
            this.extensions.Add(axInjected);
            var sreg = ExtensionsInteropHelper.UnifyExtensionsAsSreg(this.response, true);

            Assert.AreEqual("nate", sreg.Nickname);
        }
        public void SpreadSregToAxMultipleSchemas()
        {
            this.authReq.AddExtension(this.sreg);
            ExtensionsInteropHelper.SpreadSregToAX(this.authReq, AXAttributeFormats.AXSchemaOrg | AXAttributeFormats.SchemaOpenIdNet);
            var ax = this.authReq.AppliedExtensions.OfType <FetchRequest>().Single();

            Assert.IsTrue(ax.Attributes.Contains(WellKnownAttributes.Name.Alias));
            Assert.IsTrue(ax.Attributes.Contains(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet)));
            Assert.IsFalse(ax.Attributes.Contains(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.OpenIdNetSchema)));
        }
        public void SpreadSregToAxTargetedAtOPFormat()
        {
            this.authReq.AddExtension(this.sreg);
            this.InjectAdvertisedTypeUri(WellKnownAttributes.Name.FullName);
            ExtensionsInteropHelper.SpreadSregToAX(this.authReq, AXAttributeFormats.OpenIdNetSchema);
            var ax = this.authReq.AppliedExtensions.OfType <FetchRequest>().Single();

            Assert.IsFalse(ax.Attributes.Contains(ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Contact.Email, AXAttributeFormats.OpenIdNetSchema)));
            Assert.IsTrue(ax.Attributes.Contains(WellKnownAttributes.Contact.Email));
        }
 public void TransformAXFormatTest()
 {
     Assert.AreEqual(WellKnownAttributes.Name.Alias, ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.AXSchemaOrg));
     Assert.AreEqual("http://schema.openid.net/namePerson/friendly", ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.SchemaOpenIdNet));
     Assert.AreEqual("http://openid.net/schema/namePerson/friendly", ExtensionsInteropHelper.TransformAXFormatTestHook(WellKnownAttributes.Name.Alias, AXAttributeFormats.OpenIdNetSchema));
 }