コード例 #1
0
        public async Task Trivial()
        {
            var request  = new PolicyRequest();
            var response = new PolicyResponse();

            await this.RoundtripAsync(Protocol.Default, new[] { request }, new[] { response });
        }
コード例 #2
0
        public PolicyResponse CreatePolicy(PolicyRequest policyRequest)
        {
            TSeg_Polizas policy    = PolicyMapper.TransformPolicyRequestToTSegPoliza(policyRequest);
            TSeg_Polizas policyOut = PolicyDomainService.CreatePolicy(policy);

            return(policyOut != null?PolicyMapper.TransformTSegPolizaToPolicyResponse(policyOut) : null);
        }
コード例 #3
0
        private void prepareRequest(IAuthenticationRequest request)
        {
            // Collect the PAPE policies requested by the user.
            List <string> policies = new List <string>();

            foreach (ListItem item in this.papePolicies.Items)
            {
                if (item.Selected)
                {
                    policies.Add(item.Value);
                }
            }

            // Add the PAPE extension if any policy was requested.
            if (policies.Count > 0)
            {
                var pape = new PolicyRequest();
                foreach (string policy in policies)
                {
                    pape.PreferredPolicies.Add(policy);
                }

                request.AddExtension(pape);
            }
        }
コード例 #4
0
        public async Task <IActionResult> PutPolicyRequest(int id, PolicyRequest policyRequest)
        {
            if (id != policyRequest.RequestId)
            {
                return(BadRequest());
            }

            _context.Entry(policyRequest).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PolicyRequestExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #5
0
    private void prepareRequest(IAuthenticationRequest request)
    {
        // Setup is the default for the login control.  But the user may have checked the box to override that.
        request.Mode = immediateCheckBox.Checked ? AuthenticationRequestMode.Immediate : AuthenticationRequestMode.Setup;

        // Collect the PAPE policies requested by the user.
        List <string> policies = new List <string>();

        foreach (ListItem item in papePolicies.Items)
        {
            if (item.Selected)
            {
                policies.Add(item.Value);
            }
        }

        // Add the PAPE extension if any policy was requested.
        if (policies.Count > 0)
        {
            var pape = new PolicyRequest();
            foreach (string policy in policies)
            {
                pape.PreferredPolicies.Add(policy);
            }

            request.AddExtension(pape);
        }
    }
コード例 #6
0
        public ActionResult AddCovering(long policyId, string coveringName)
        {
            PolicyResponse policy = PolicyApplicationService.ReadPolicyById(policyId);

            try
            {
                PolicyRequest request = new PolicyRequest
                {
                    id                    = policy.id,
                    descripcion           = policy.descripcion,
                    nombre                = policy.nombre,
                    TSeg_Tipo_Cubrimiento = getCoveringTypes(policy, coveringName)
                };

                int response = PolicyApplicationService.UpdatePolicy(request);
                return(RedirectToAction("Details", new { id = policyId }));
            }
            catch
            {
                ViewBag.PolicyName = policy.nombre;
                ViewBag.PolicyId   = policy.id;

                ViewBag.Error = "El tipo de cubrimiento no se pudo adicionar.";

                return(View("~/Views/Policies/AddCovering.cshtml"));
            }
        }
コード例 #7
0
        public void Trivial()
        {
            var request  = new PolicyRequest();
            var response = new PolicyResponse();

            ExtensionTestUtilities.Roundtrip(Protocol.Default, new[] { request }, new[] { response });
        }
コード例 #8
0
ファイル: PolicyTests.cs プロジェクト: ahives/HareDu3
        public async Task Verify_can_create_policy1()
        {
            var services = GetContainerBuilder().BuildServiceProvider();
            var result   = await services.GetService <IBrokerObjectFactory>()
                           .Object <Policy>()
                           .Create("P5", "^amq.", "HareDu", x =>
            {
                x.SetHighAvailabilityMode(HighAvailabilityModes.All);
                x.SetExpiry(1000);
            }, PolicyAppliedTo.All, 0);

            Assert.Multiple(() =>
            {
                Assert.IsFalse(result.HasFaulted);
                Assert.IsNotNull(result.DebugInfo);

                PolicyRequest request = result.DebugInfo.Request.ToObject <PolicyRequest>(Deserializer.Options);

                Assert.AreEqual("^amq.", request.Pattern);
                Assert.AreEqual(0, request.Priority);
                Assert.AreEqual("all", request.Arguments["ha-mode"]);
                Assert.AreEqual("1000", request.Arguments["expires"]);
                Assert.AreEqual(PolicyAppliedTo.All, request.ApplyTo);
            });
        }
コード例 #9
0
ファイル: PolicyRequestTests.cs プロジェクト: tt/dotnetopenid
 public void Ctor()
 {
     PolicyRequest req = new PolicyRequest();
     Assert.IsNull(req.MaximumAuthenticationAge);
     Assert.IsNotNull(req.PreferredPolicies);
     Assert.AreEqual(0, req.PreferredPolicies.Count);
 }
コード例 #10
0
ファイル: PolicyRequestTests.cs プロジェクト: tt/dotnetopenid
        public void EqualsTest()
        {
            PolicyRequest req = new PolicyRequest();
            PolicyRequest req2 = new PolicyRequest();
            Assert.AreEqual(req, req2);
            Assert.AreNotEqual(req, null);
            Assert.AreNotEqual(null, req);

            // Test PreferredPolicies list comparison
            req.PreferredPolicies.Add(AuthenticationPolicies.PhishingResistant);
            Assert.AreNotEqual(req, req2);
            req2.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
            Assert.AreNotEqual(req, req2);
            req2.PreferredPolicies.Clear();
            req2.PreferredPolicies.Add(AuthenticationPolicies.PhishingResistant);
            Assert.AreEqual(req, req2);

            // Test PreferredPolicies list comparison when that list is not in the same order.
            req.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
            Assert.AreNotEqual(req, req2);
            req2.PreferredPolicies.Insert(0, AuthenticationPolicies.MultiFactor);
            Assert.AreEqual(req, req2);

            // Test MaximumAuthenticationAge comparison.
            req.MaximumAuthenticationAge = TimeSpan.FromHours(1);
            Assert.AreNotEqual(req, req2);
            req2.MaximumAuthenticationAge = req.MaximumAuthenticationAge;
            Assert.AreEqual(req, req2);
        }
コード例 #11
0
        public async Task <ActionResult <PolicyRequest> > PostPolicyRequest(PolicyRequest policyRequest)
        {
            _context.PolicyRequest.Add(policyRequest);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPolicyRequest", new { id = policyRequest.RequestId }, policyRequest));
        }
コード例 #12
0
ファイル: login.aspx.cs プロジェクト: terry2012/DSV
        private void prepareRequest(IAuthenticationRequest request)
        {
            // Collect the PAPE policies requested by the user.
            List <string> policies = new List <string>();

            foreach (ListItem item in this.papePolicies.Items)
            {
                if (item.Selected)
                {
                    policies.Add(item.Value);
                }
            }

            // Add the PAPE extension if any policy was requested.
            var pape = new PolicyRequest();

            if (policies.Count > 0)
            {
                foreach (string policy in policies)
                {
                    pape.PreferredPolicies.Add(policy);
                }
            }

            if (this.maxAuthTimeBox.Text.Length > 0)
            {
                pape.MaximumAuthenticationAge = TimeSpan.FromSeconds(double.Parse(this.maxAuthTimeBox.Text));
            }

            if (pape.PreferredPolicies.Count > 0 || pape.MaximumAuthenticationAge.HasValue)
            {
                request.AddExtension(pape);
            }
        }
コード例 #13
0
        public Response SavePolicyDetailsRequest(Dictionary <string, object> parameters)
        {
            try
            {
                var insReq  = new InsuranceRequest();
                var sess    = new SessionRequest();
                var vehicle = new VehicleRequest();
                var client  = new ClientRequest();
                var policy  = new PolicyRequest();

                sess.Username              = (String)parameters["username"];
                sess.AuthenticationKey     = (String)parameters["AuthenticationKey"];
                sess.Bordereaux            = (bool)parameters["bordereaux"];
                sess.Account               = (String)parameters["account"];
                sess.GuaranteeWarrantyDate = (DateTime)parameters["guarenteewarrantydate"];
                sess.PaidByCard            = (bool)parameters["paidbycard"];
                sess.DeliveryDate          = (DateTime)parameters["deliverydate"];
                sess.LoanProvided          = (bool)parameters["loanprovided"];

                client.FirstName   = (String)parameters["firstname"];
                client.Surname     = (String)parameters["surname"];
                client.Title       = (String)parameters["title"];
                client.HouseNumber = (String)parameters["housenumber"];
                client.Address     = (String)parameters["address"];
                client.Postcode    = (String)parameters["postcode"];
                client.Email       = (String)parameters["email"];
                client.Telephone   = (String)parameters["telephone"];
                client.IsCompany   = (bool)parameters["iscompany"];

                policy.Description  = (String)parameters["description"];
                policy.Plan         = (String)parameters["plan"];
                policy.GrossPremium = (decimal)parameters["grosspremium"];
                policy.Product      = (String)parameters["product"];
                policy.CoverPeriod  = (int)parameters["coverperiod"];

                vehicle.Make           = (String)parameters["make"];
                vehicle.Model          = (String)parameters["model"];
                vehicle.Registration   = (String)parameters["registration"];
                vehicle.Price          = (decimal)parameters["price"];
                vehicle.Mileage        = (int)parameters["mileage"];
                vehicle.DateRegistered = (DateTime)parameters["dateregistered"];
                vehicle.EngineSize     = (int)parameters["enginesize"];
                vehicle.Fuel           = (String)parameters["fuel"];
                vehicle.NewVehicle     = (bool)parameters["newvehicle"];
                vehicle.Motorcycle     = (bool)parameters["motorcycle"];

                insReq.Session = sess;
                insReq.Client  = client;
                insReq.Policy  = policy;
                insReq.Vehicle = vehicle;

                var response = insuranceWebService.SavePolicyDetailsRequest(insReq);
                return(MethodRespToObject(response));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException.Message);
                return(null);
            }
        }
コード例 #14
0
        static void sadMain(string[] args)
        {
            InsuranceWebService insuranceWebService = new InsuranceWebService();
            var insRequest = new InsuranceRequest();
            var mySession  = new SessionRequest();
            var myPolicy   = new PolicyRequest();
            var myClient   = new ClientRequest();
            var myVehicle  = new VehicleRequest();

            mySession.Username              = "";
            mySession.AuthenticationKey     = "";
            mySession.Bordereaux            = false;
            mySession.Account               = "";
            mySession.GuaranteeWarrantyDate = new DateTime();
            mySession.PaidByCard            = true;
            mySession.DeliveryDate          = new DateTime();
            mySession.LoanProvided          = false;

            myClient.FirstName   = "";
            myClient.Surname     = "";
            myClient.Title       = "";
            myClient.HouseNumber = "";
            myClient.Address     = "";
            myClient.Postcode    = "";
            myClient.Email       = "";
            myClient.Telephone   = "";
            myClient.IsCompany   = false;

            myPolicy.Description  = "";
            myPolicy.Plan         = "";
            myPolicy.GrossPremium = 0;
            myPolicy.Product      = "";
            myPolicy.CoverPeriod  = 0;

            myVehicle.Make           = "";
            myVehicle.Model          = "";
            myVehicle.Registration   = "";
            myVehicle.Price          = 0;
            myVehicle.Mileage        = 0;
            myVehicle.DateRegistered = new DateTime();
            myVehicle.EngineSize     = 0;
            myVehicle.Fuel           = "";
            myVehicle.NewVehicle     = false;
            myVehicle.Motorcycle     = false;


            insRequest.Session = mySession;
            insRequest.Vehicle = myVehicle;
            insRequest.Client  = myClient;
            insRequest.Policy  = myPolicy;

            var response = insuranceWebService.GetIncludedMakesRequest(insRequest);

            foreach (var p in response.GetVehicleList)
            {
                Console.WriteLine(p);
            }
            Console.ReadKey();
        }
コード例 #15
0
        public void Ctor()
        {
            PolicyRequest req = new PolicyRequest();

            Assert.IsNull(req.MaximumAuthenticationAge);
            Assert.IsNotNull(req.PreferredPolicies);
            Assert.AreEqual(0, req.PreferredPolicies.Count);
        }
コード例 #16
0
        public void AddAuthLevelTypes()
        {
            PolicyRequest req = new PolicyRequest();

            req.PreferredAuthLevelTypes.Add(Constants.AssuranceLevels.NistTypeUri);
            Assert.AreEqual(1, req.PreferredAuthLevelTypes.Count);
            Assert.IsTrue(req.PreferredAuthLevelTypes.Contains(Constants.AssuranceLevels.NistTypeUri));
        }
コード例 #17
0
ファイル: Policy.cs プロジェクト: jamestoyer/Vault.NET
        public Task PutPolicy(string name, string rules, CancellationToken ct = default(CancellationToken))
        {
            var request = new PolicyRequest
            {
                Rules = rules
            };

            return(_client.PutVoid($"{UriPathBase}/policy/{name}", request, ct));
        }
コード例 #18
0
ファイル: PolicyRequestTests.cs プロジェクト: tt/dotnetopenid
 public void AddPolicies()
 {
     PolicyRequest resp = new PolicyRequest();
     resp.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
     resp.PreferredPolicies.Add(AuthenticationPolicies.PhishingResistant);
     Assert.AreEqual(2, resp.PreferredPolicies.Count);
     Assert.AreEqual(AuthenticationPolicies.MultiFactor, resp.PreferredPolicies[0]);
     Assert.AreEqual(AuthenticationPolicies.PhishingResistant, resp.PreferredPolicies[1]);
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: ramnadh/designenablement
        static IPolicyServeStrategy GetStrategyProduct(PolicyRequest request)
        {
            if (request.ServiceType.Equals(PolicyServiceType.FAST_TRACK))
            {
                return(new FastTrackService(request));
            }

            return(new StandardService(request));
        }
コード例 #20
0
ファイル: PolicyMapper.cs プロジェクト: jrengifo88/Seguros
 public static TSeg_Polizas TransformPolicyRequestToTSegPoliza(PolicyRequest policyRequest)
 {
     return(new TSeg_Polizas
     {
         nombre = policyRequest.nombre,
         descripcion = policyRequest.descripcion,
         id = policyRequest.id,
         TSeg_Tipo_Cubrimiento = getCoveringTypesFromPolicyRequest(policyRequest)
     });
 }
コード例 #21
0
        public ActionResult <PolicyResponse> AddPolicy(PolicyRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var policy = _userManagementRepository.AddPolicy(request);

            return(CreatedAtRoute("GetPolicyById", new { policyId = policy.PolicyId }, policy));
        }
コード例 #22
0
        public void AddPolicies()
        {
            PolicyRequest resp = new PolicyRequest();

            resp.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
            resp.PreferredPolicies.Add(AuthenticationPolicies.PhishingResistant);
            Assert.AreEqual(2, resp.PreferredPolicies.Count);
            Assert.AreEqual(AuthenticationPolicies.MultiFactor, resp.PreferredPolicies[0]);
            Assert.AreEqual(AuthenticationPolicies.PhishingResistant, resp.PreferredPolicies[1]);
        }
コード例 #23
0
        public void MaximumAuthenticationAgeTest()
        {
            PolicyRequest req = new PolicyRequest();

            req.MaximumAuthenticationAge = TimeSpan.FromHours(1);
            Assert.IsNotNull(req.MaximumAuthenticationAge);
            Assert.AreEqual(TimeSpan.FromHours(1), req.MaximumAuthenticationAge);
            req.MaximumAuthenticationAge = null;
            Assert.IsNull(req.MaximumAuthenticationAge);
        }
コード例 #24
0
        public ActionResult <PolicyResponse> UpdatePolicy(PolicyRequest request, int policyId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var policy = _userManagementRepository.UpdatePolicy(request, policyId);

            return(NoContent());
        }
コード例 #25
0
ファイル: PapeTests.cs プロジェクト: tt/dotnetopenid
 public void Full()
 {
     var request = new PolicyRequest();
     request.MaximumAuthenticationAge = TimeSpan.FromMinutes(10);
     var response = ParameterizedTest<PolicyResponse>(
         TestSupport.Scenarios.ExtensionFullCooperation, Version, request);
     Assert.IsNotNull(response);
     Assert.IsNotNull(response.AuthenticationTimeUtc);
     Assert.IsTrue(response.AuthenticationTimeUtc.Value > DateTime.UtcNow - request.MaximumAuthenticationAge);
 }
コード例 #26
0
ファイル: PolicyRequestTests.cs プロジェクト: tt/dotnetopenid
 public void AddPolicyMultipleTimes()
 {
     // Although this isn't really the desired behavior (we'd prefer to see an
     // exception thrown), since we're using a List<string> internally we can't
     // expect anything better (for now).  But if this is ever fixed, by all means
     // change this test to expect an exception or something else.
     PolicyRequest resp = new PolicyRequest();
     resp.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
     resp.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
     Assert.AreEqual(2, resp.PreferredPolicies.Count);
 }
コード例 #27
0
 public void handlePacketData(byte[] packet)
 {
     if (packet[0] == 60 && PolicyRequest != null)
     {
         PolicyRequest.Invoke();
     }
     else if (packet[0] != 67 && SwitchParserRequest != null)
     {
         SwitchParserRequest.Invoke(packet);
     }
 }
コード例 #28
0
 public void HandlePacketData(byte[] Packet)
 {
     if (Packet[0] == 60 && PolicyRequest != null)
     {
         PolicyRequest.Invoke();
     }
     else if (Packet[0] != 67 && SwitchParserRequest != null)
     {
         CurrentData = Packet;
         SwitchParserRequest.Invoke();
     }
 }
コード例 #29
0
        public void AddPolicyMultipleTimes()
        {
            // Although this isn't really the desired behavior (we'd prefer to see an
            // exception thrown), since we're using a List<string> internally we can't
            // expect anything better (for now).  But if this is ever fixed, by all means
            // change this test to expect an exception or something else.
            PolicyRequest resp = new PolicyRequest();

            resp.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
            resp.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
            Assert.AreEqual(2, resp.PreferredPolicies.Count);
        }
コード例 #30
0
        public async Task <ActionResult <Policy> > Post(PolicyRequest request)
        {
            Policy policy = Policy.GetPolicyFromRequest(request);

            if (policy != null && Policy.ValidPolicy(policy))
            {
                _context.Policies.Add(policy);
                await _context.SaveChangesAsync();

                return(CreatedAtAction(nameof(Get), new { id = policy.ID }, policy));
            }
            return(BadRequest());
        }
コード例 #31
0
 public int UpdatePolicy(PolicyRequest policyRequest)
 {
     try
     {
         TSeg_Polizas policy = PolicyMapper.TransformPolicyRequestToTSegPoliza(policyRequest);
         PolicyDomainService.UpdatePolicy(policy);
         return(1);
     }
     catch (Exception e)
     {
         return(-1);
     }
 }
コード例 #32
0
ファイル: PapeTests.cs プロジェクト: Belxjander/Asuna
		public void Full() {
			var request = new PolicyRequest();
			request.MaximumAuthenticationAge = TimeSpan.FromMinutes(10);
			request.PreferredAuthLevelTypes.Add(Constants.AuthenticationLevels.NistTypeUri);
			var response = ParameterizedTest<PolicyResponse>(
				TestSupport.Scenarios.ExtensionFullCooperation, Version, request);
			Assert.IsNotNull(response);
			Assert.IsNotNull(response.AuthenticationTimeUtc);
			Assert.IsTrue(response.AuthenticationTimeUtc.Value > DateTime.UtcNow - request.MaximumAuthenticationAge);
			Assert.IsTrue(response.AssuranceLevels.ContainsKey(Constants.AuthenticationLevels.NistTypeUri));
			Assert.AreEqual("1", response.AssuranceLevels[Constants.AuthenticationLevels.NistTypeUri]);
			Assert.AreEqual(NistAssuranceLevel.Level1, response.NistAssuranceLevel);
		}
コード例 #33
0
        public ActionResult Create(PolicyRequest policy)
        {
            PolicyResponse response = PolicyApplicationService.CreatePolicy(policy);

            if (response.id > 0)
            {
                return(RedirectToAction("Policies"));
            }
            else
            {
                ViewBag.Error = "La póliza no pudo ser creada.";
                return(View("~/Views/Policies/Create.cshtml"));
            }
        }
コード例 #34
0
        public async Task <Customer> GetCustomerLinkedToPolicyByNumberAsync(PolicyRequest request, CancellationToken cancellationToken)
        {
            var client = await _httpProxy.GetCustomersAsync(cancellationToken);

            var policies = await _httpProxy.GetPoliciesAsync(cancellationToken);

            var policySelect = policies.Policies.FirstOrDefault(policy => policy.Id == request.Id);

            if (policySelect != null)
            {
                return(client.Clients.FirstOrDefault(customer => customer.Id == policySelect.ClientId));
            }

            return(null);
        }
コード例 #35
0
        public void Full()
        {
            var request = new PolicyRequest();

            request.MaximumAuthenticationAge = TimeSpan.FromMinutes(10);
            request.PreferredAuthLevelTypes.Add(Constants.AuthenticationLevels.NistTypeUri);
            var response = ParameterizedTest <PolicyResponse>(
                TestSupport.Scenarios.ExtensionFullCooperation, Version, request);

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.AuthenticationTimeUtc);
            Assert.IsTrue(response.AuthenticationTimeUtc.Value > DateTime.UtcNow - request.MaximumAuthenticationAge);
            Assert.IsTrue(response.AssuranceLevels.ContainsKey(Constants.AuthenticationLevels.NistTypeUri));
            Assert.AreEqual("1", response.AssuranceLevels[Constants.AuthenticationLevels.NistTypeUri]);
            Assert.AreEqual(NistAssuranceLevel.Level1, response.NistAssuranceLevel);
        }
コード例 #36
0
        public async Task <ActionResult <Policy> > Put(int id, PolicyRequest request)
        {
            if (id != request.ID)
            {
                return(BadRequest());
            }
            Policy policy = Policy.GetPolicyFromRequest(request);

            if (policy != null && Policy.ValidPolicy(policy))
            {
                _context.Entry(policy).State = EntityState.Modified;
            }
            await _context.SaveChangesAsync();

            return(NoContent());
        }
コード例 #37
0
ファイル: login.aspx.cs プロジェクト: Belxjander/Asuna
	private void prepareRequest(IAuthenticationRequest request) {
		// Setup is the default for the login control.  But the user may have checked the box to override that.
		request.Mode = immediateCheckBox.Checked ? AuthenticationRequestMode.Immediate : AuthenticationRequestMode.Setup;

		// Collect the PAPE policies requested by the user.
		List<string> policies = new List<string>();
		foreach (ListItem item in papePolicies.Items) {
			if (item.Selected) {
				policies.Add(item.Value);
			}
		}

		// Add the PAPE extension if any policy was requested.
		if (policies.Count > 0) {
			var pape = new PolicyRequest();
			foreach (string policy in policies) {
				pape.PreferredPolicies.Add(policy);
			}

			request.AddExtension(pape);
		}
	}
コード例 #38
0
ファイル: PolicyRequestTests.cs プロジェクト: tt/dotnetopenid
        public void SerializeRoundTrip()
        {
            // This test relies on the PolicyRequest.Equals method.  If this and that test
            // are failing, work on EqualsTest first.

            // Most basic test
            PolicyRequest req = new PolicyRequest(), req2 = new PolicyRequest();
            var fields = ((IExtensionRequest)req).Serialize(null);
            Assert.IsTrue(((IExtensionRequest)req2).Deserialize(fields, null, Constants.TypeUri));
            Assert.AreEqual(req, req2);

            // Test with all fields set
            req2 = new PolicyRequest();
            req.PreferredPolicies.Add(AuthenticationPolicies.MultiFactor);
            req.MaximumAuthenticationAge = TimeSpan.FromHours(1);
            fields = ((IExtensionRequest)req).Serialize(null);
            Assert.IsTrue(((IExtensionRequest)req2).Deserialize(fields, null, Constants.TypeUri));
            Assert.AreEqual(req, req2);

            // Test with an extra policy
            req2 = new PolicyRequest();
            req.PreferredPolicies.Add(AuthenticationPolicies.PhishingResistant);
            fields = ((IExtensionRequest)req).Serialize(null);
            Assert.IsTrue(((IExtensionRequest)req2).Deserialize(fields, null, Constants.TypeUri));
            Assert.AreEqual(req, req2);

            // Test with a policy added twice.  We should see it intelligently leave one of
            // the doubled policies out.
            req2 = new PolicyRequest();
            req.PreferredPolicies.Add(AuthenticationPolicies.PhishingResistant);
            fields = ((IExtensionRequest)req).Serialize(null);
            Assert.IsTrue(((IExtensionRequest)req2).Deserialize(fields, null, Constants.TypeUri));
            Assert.AreNotEqual(req, req2);
            // Now go ahead and add the doubled one so we can do our equality test.
            req2.PreferredPolicies.Add(AuthenticationPolicies.PhishingResistant);
            Assert.AreEqual(req, req2);
        }
コード例 #39
0
ファイル: PolicyRequestTests.cs プロジェクト: tt/dotnetopenid
 public void MaximumAuthenticationAgeTest()
 {
     PolicyRequest req = new PolicyRequest();
     req.MaximumAuthenticationAge = TimeSpan.FromHours(1);
     Assert.IsNotNull(req.MaximumAuthenticationAge);
     Assert.AreEqual(TimeSpan.FromHours(1), req.MaximumAuthenticationAge);
     req.MaximumAuthenticationAge = null;
     Assert.IsNull(req.MaximumAuthenticationAge);
 }
コード例 #40
0
ファイル: PolicyRequestTests.cs プロジェクト: tt/dotnetopenid
 public void DeserializeNull()
 {
     PolicyRequest req = new PolicyRequest();
     Assert.IsFalse(((IExtensionRequest)req).Deserialize(null, null, Constants.TypeUri));
 }
コード例 #41
0
ファイル: PolicyRequestTests.cs プロジェクト: tt/dotnetopenid
 public void DeserializeEmpty()
 {
     PolicyRequest req = new PolicyRequest();
     Assert.IsFalse(((IExtensionRequest)req).Deserialize(new Dictionary<string, string>(), null, Constants.TypeUri));
 }