void CreateProviderOpenGetToken(bool getToken) { MyParameters tp = new MyParameters(); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement(); tp.InitRequirement(r); r.TargetAddress = new EndpointAddress("http://localhost:8080"); r.SecurityBindingElement = new SymmetricSecurityBindingElement(); r.Properties [ReqType.IssuerBindingContextProperty] = new BindingContext(new CustomBinding(new HttpTransportBindingElement()), new BindingParameterCollection()); r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion; // This is required at GetToken(). r.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default; ClientCredentials cred = new ClientCredentials(); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager(cred); // TLS negotiation token provider is created. SecurityTokenProvider p = manager.CreateSecurityTokenProvider(r); ((ICommunicationObject)p).Open(); if (!getToken) { return; } p.GetToken(TimeSpan.FromSeconds(5)); }
public void DefaultValues() { MyParameters p = new MyParameters(); Assert.IsNull(p.BootstrapSecurityBindingElement, "#1-1"); Assert.IsNotNull(p.BootstrapProtectionRequirements, "#1-2"); Assert.AreEqual(true, p.RequireCancellation, "#1-3"); Assert.AreEqual(false, p.Asym, "#1-4"); // they cause NRE on winfx, likely a bug. //Assert.AreEqual (true, p.Client, "#1-5"); //Assert.AreEqual (true, p.Win, "#1-6"); //Assert.AreEqual (true, p.Server, "#1-7"); p = new MyParameters(new AsymmetricSecurityBindingElement()); Assert.IsNotNull(p.BootstrapSecurityBindingElement, "#2-1"); Assert.IsNotNull(p.BootstrapProtectionRequirements, "#2-2"); Assert.AreEqual(true, p.RequireCancellation, "#2-3"); Assert.AreEqual(false, p.Asym, "#2-4"); // regardless of binding element. Assert.AreEqual(false, p.Client, "#2-5"); Assert.AreEqual(false, p.Win, "#2-6"); Assert.AreEqual(false, p.Server, "#2-7"); ChannelProtectionRequirements r = p.BootstrapProtectionRequirements; Assert.IsTrue(r.IncomingSignatureParts.ChannelParts.IsBodyIncluded, "#3-1"); Assert.IsTrue(r.OutgoingSignatureParts.ChannelParts.IsBodyIncluded, "#3-2"); Assert.IsTrue(r.IncomingEncryptionParts.ChannelParts.IsBodyIncluded, "#3-3"); Assert.IsTrue(r.OutgoingEncryptionParts.ChannelParts.IsBodyIncluded, "#3-4"); }
public void FromQueryString() { #if NETSTANDARD var queryString = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery("q=test&options=o1&options=o2&numbers=1&numbers=5&doubles=99.99&doubles=8&lat=-53.3&lng=3.234&location=1,2&sortdir=Asc&enumOptions=optionone"); #else var queryString = System.Web.HttpUtility.ParseQueryString("q=test&options=o1&options=o2&numbers=1&numbers=5&doubles=99.99&doubles=8&lat=-53.3&lng=3.234&location=1,2&sortdir=Asc&enumOptions=optionone"); #endif var p = new MyParameters(); QueryStringParser <MyParameters> .Populate(queryString, p); p.Query.Should().Be("test"); p.Page.Should().Be(1); p.Size.Should().Be(10); p.Options.Should().NotBeNull(); p.Options.Count().Should().Be(2); p.Numbers.Count().Should().Be(2); p.Doubles.Count().Should().Be(2); p.Latitude.Should().Be(-53.3); p.Longitude.Should().Be(3.234); p.Location.Latitude.Should().Be(1); p.Location.Longitude.Should().Be(2); p.SortDirection.Should().Be(SortDirectionOption.Asc); p.EnumOptions.Should().Be(SomeOption.OptionOne); }
private void MakeJsonRequest() { //elRequest = new Elasticrequest(); if (MyParameters.ContainsKey("SearchString")) { jsonReq = new JsonRequest(MyParameters["SearchString"]); } }
//private void MakeElRequest(SerializableDictionary<string, string> ) private void MakeElRequest() { //elRequest = new Elasticrequest(); if (MyParameters.ContainsKey("SearchString")) { elRequest.Filters.MainSearchBar.Value = MyParameters["SearchString"]; } }
public void Should_Return_Null_When_File_Does_Not_Exists() { // Arrange // Act var loadParmeters = new MyParameters().Load("NonExists.xml"); // Assert Assert.Null(loadParmeters); }
public void InitializeSecurityTokenParameters() { MyParameters tp = new MyParameters(); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement(); tp.InitRequirement(r); Assert.AreEqual(ServiceModelSecurityTokenTypes.Spnego, r.TokenType, "#1"); Assert.AreEqual(false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2"); }
public void DefaultValues () { MyParameters tp = new MyParameters (); Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, tp.InclusionMode, "#1"); Assert.AreEqual (SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2"); Assert.AreEqual (true, tp.RequireDerivedKeys, "#3"); Assert.AreEqual (false, tp.HasAsymmetricKeyEx, "#4"); Assert.AreEqual (true, tp.SupportsClientAuthenticationEx, "#5"); Assert.AreEqual (false, tp.SupportsClientWindowsIdentityEx, "#6"); Assert.AreEqual (true, tp.SupportsServerAuthenticationEx, "#7"); }
public void DefaultValues() { MyParameters tp = new MyParameters(); Assert.AreEqual(SecurityTokenInclusionMode.AlwaysToRecipient, tp.InclusionMode, "#1"); Assert.AreEqual(SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2"); Assert.AreEqual(true, tp.RequireDerivedKeys, "#3"); Assert.AreEqual(false, tp.HasAsymmetricKeyEx, "#4"); Assert.AreEqual(true, tp.SupportsClientAuthenticationEx, "#5"); Assert.AreEqual(false, tp.SupportsClientWindowsIdentityEx, "#6"); Assert.AreEqual(true, tp.SupportsServerAuthenticationEx, "#7"); }
public void InitializeSecurityTokenParameters() { MyParameters tp = new MyParameters(); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement(); tp.InitRequirement(r); Assert.AreEqual(ServiceModelSecurityTokenTypes.AnonymousSslnego, r.TokenType, "#1"); Assert.AreEqual(false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2"); SslSecurityTokenParameters dummy; Assert.IsTrue(r.TryGetProperty <SslSecurityTokenParameters> (ReqType.IssuedSecurityTokenParametersProperty, out dummy), "#3"); }
public void CreateProviderNoTargetAddress() { MyParameters tp = new MyParameters(); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement(); tp.InitRequirement(r); ClientCredentials cred = new ClientCredentials(); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager(cred); manager.CreateSecurityTokenProvider(r); }
public void CreateKeyIdentifierClauseSCT() { MyParameters tp = new MyParameters(); SecurityContextSecurityToken sct = new SecurityContextSecurityToken(new UniqueId(), new byte [32], DateTime.MinValue, DateTime.MaxValue); SecurityKeyIdentifierClause kic = tp.CallCreateKeyIdentifierClause(sct, SecurityTokenReferenceStyle.Internal); Assert.IsTrue(kic is LocalIdKeyIdentifierClause, "#1"); SecurityContextKeyIdentifierClause scic = tp.CallCreateKeyIdentifierClause(sct, SecurityTokenReferenceStyle.External) as SecurityContextKeyIdentifierClause; Assert.IsNotNull(scic, "#2"); Assert.IsNull(scic.Generation, "#3"); }
public void CreateProviderNoSecurityBindingElement() { MyParameters tp = new MyParameters(); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement(); tp.InitRequirement(r); r.TargetAddress = new EndpointAddress("http://localhost:8080"); ClientCredentials cred = new ClientCredentials(); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager(cred); manager.CreateSecurityTokenProvider(r); }
public void ToQueryString() { var p = new MyParameters { Query = "test", Options = new[] { "o1", "o2" }, Numbers = new[] { 1, 5 }, Doubles = new[] { 2.3, 17.5 }, LongValue = 999999999, LongValues = new long[] { 11111111, 22222222, 33333333 } }; var nvc = QueryStringParser <MyParameters> .Parse(p); nvc.Count.Should().Be(6); }
public void MyProperty2_Should_Return_ExpectedResult() { // Arrange var parameters = new MyParameters(); parameters.MyProperty2 = "Another Test"; var filename = Guid.NewGuid().ToString() + ".xml"; // Act parameters.Save(filename); var loadParameters = new MyParameters().Load(filename); // Assert Assert.Equal(loadParameters.MyProperty2, parameters.MyProperty2); }
public void ToQueryString() { var p = new MyParameters { Query = "test", Options = new[] { "o1", "o2" }, Numbers = new[] { 1, 5 }, Doubles = new[] { 2.3, 17.5 }, Latitude = -53.1, Longitude = -3, Location = GeoLocation.TryCreate(-53.1, -3) }; var nvc = QueryStringParser <MyParameters> .Parse(p); nvc.Count.Should().Be(7); }
public void Load_Should_Returne_ExpectedResult_When_CurrentDirectoryIsNotAssemblyPath() { // Arrange var parameters = new MyParameters(); parameters.MyProperty1 = 10; var filename = Guid.NewGuid().ToString() + ".xml"; parameters.Save(filename); // Act Directory.SetCurrentDirectory(Environment.GetEnvironmentVariable("TEMP")); var loadParameters = new MyParameters().Load(filename); // Assert Assert.Equal(loadParameters.MyProperty1, parameters.MyProperty1); }
public void CreateAuthenticator() { MyParameters tp = new MyParameters(); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement(); tp.InitRequirement(r); ClientCredentials cred = new ClientCredentials(); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager(cred); SecurityTokenResolver resolver; // SecurityTokenAuthenticator authenticator = manager.CreateSecurityTokenAuthenticator(r, out resolver); }
public void CreateProviderNoMessageSecurityVersion() { MyParameters tp = new MyParameters(); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement(); tp.InitRequirement(r); r.TargetAddress = new EndpointAddress("http://localhost:8080"); r.SecurityBindingElement = new SymmetricSecurityBindingElement(); r.Properties [ReqType.IssuerBindingContextProperty] = new BindingContext(new CustomBinding(), new BindingParameterCollection()); ClientCredentials cred = new ClientCredentials(); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager(cred); manager.CreateSecurityTokenProvider(r); }
public void FromQueryString() { var queryString = HttpUtility.ParseQueryString("q=test&options=o1&options=o2&numbers=1&numbers=5&doubles=99.99&doubles=8&lat=-53.3&lng=3.234&location=1,2&sortdir=Asc&enumOptions=optionone"); var p = new MyParameters(); QueryStringParser <MyParameters> .Populate(queryString, p); p.Query.Should().Be("test"); p.Page.Should().Be(1); p.Size.Should().Be(10); p.Options.Should().NotBeNull(); p.Options.Count().Should().Be(2); p.Numbers.Count().Should().Be(2); p.Doubles.Count().Should().Be(2); p.Latitude.Should().Be(-53.3); p.Longitude.Should().Be(3.234); p.Location.Latitude.Should().Be(1); p.Location.Longitude.Should().Be(2); p.SortDirection.Should().Be(SortDirectionOption.Asc); p.EnumOptions.Should().Be(SomeOption.OptionOne); }
public void FromQueryString() { var queryString = HttpUtility.ParseQueryString("q=test&options=o1&options=o2&numbers=1&numbers=5&doubles=99.99&doubles=8&lat=-53.3&lng=3.234&location=1,2&sortdir=Asc&enumOptions=optionone"); var p = new MyParameters(); QueryStringParser<MyParameters>.Populate(queryString, p); p.Query.Should().Be("test"); p.Page.Should().Be(1); p.Size.Should().Be(10); p.Options.Should().NotBeNull(); p.Options.Count().Should().Be(2); p.Numbers.Count().Should().Be(2); p.Doubles.Count().Should().Be(2); p.Latitude.Should().Be(-53.3); p.Longitude.Should().Be(3.234); p.Location.Latitude.Should().Be(1); p.Location.Longitude.Should().Be(2); p.SortDirection.Should().Be(SortDirectionOption.Asc); p.EnumOptions.Should().Be(SomeOption.OptionOne); }
public void ToQueryString() { var p = new MyParameters(); p.Query = "test"; p.Options = new[] { "o1", "o2" }; p.Numbers = new[] { 1, 5 }; p.Doubles = new[] { 2.3, 17.5 }; p.Latitude = -53.1; p.Longitude = -3; p.Location = GeoPoint.TryCreate(-53.1, -3); var nvc = QueryStringParser <MyParameters> .Parse(p); nvc.Count.Should().Be(7); foreach (var item in nvc.AllKeys) { Console.WriteLine($"{item} => {nvc.Get(item)}"); } Console.WriteLine(nvc); }
void CreateRecipientProviderCore(bool mutual) { MyParameters tp = new MyParameters(); tp.RequireClientCertificate = true; RecipientServiceModelSecurityTokenRequirement r = new RecipientServiceModelSecurityTokenRequirement(); tp.InitRequirement(r); r.ListenUri = new Uri("http://localhost:8080"); r.SecurityBindingElement = new SymmetricSecurityBindingElement(); r.Properties [ReqType.IssuerBindingContextProperty] = new BindingContext(new CustomBinding(), new BindingParameterCollection()); r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion; ClientCredentials cred = new ClientCredentials(); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager(cred); manager.CreateSecurityTokenProvider(r); }
public void CreateKeyIdentifierClauseSCT () { MyParameters tp = new MyParameters (); SecurityContextSecurityToken sct = new SecurityContextSecurityToken (new UniqueId (), new byte [32], DateTime.MinValue, DateTime.MaxValue); SecurityKeyIdentifierClause kic = tp.CallCreateKeyIdentifierClause (sct, SecurityTokenReferenceStyle.Internal); Assert.IsTrue (kic is LocalIdKeyIdentifierClause, "#1"); SecurityContextKeyIdentifierClause scic = tp.CallCreateKeyIdentifierClause (sct, SecurityTokenReferenceStyle.External) as SecurityContextKeyIdentifierClause; Assert.IsNotNull (scic, "#2"); Assert.IsNull (scic.Generation, "#3"); }
public void InitializeSecurityTokenParameters () { MyParameters tp = new MyParameters (); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement (); tp.InitRequirement (r); Assert.AreEqual (ServiceModelSecurityTokenTypes.Spnego, r.TokenType, "#1"); Assert.AreEqual (false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2"); }
public void CreateProvider () { MyParameters tp = new MyParameters (); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement (); tp.InitRequirement (r); r.TargetAddress = new EndpointAddress ("http://localhost:8080"); r.SecurityBindingElement = new SymmetricSecurityBindingElement (); r.Properties [ReqType.IssuerBindingContextProperty] = new BindingContext (new CustomBinding (), new BindingParameterCollection ()); r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion; ClientCredentials cred = new ClientCredentials (); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager (cred); //SecurityTokenProvider p = manager.CreateSecurityTokenProvider (r); }
private MyParameters GetMyParameters() { MyParameters myparams = new MyParameters(); if (rngp_Uploader.GetValue() != null) { myparams.Uploader = rngp_Uploader.GetValue().ToString(); } return myparams; }
private MyParameters GetMyParameters() { MyParameters myparams = new MyParameters(); int delta = DayOfWeek.Monday - DateTime.Now.DayOfWeek; myparams.RequestedDate = DateTime.Now.AddDays(delta).ToString("yyyy-MM-dd"); return myparams; }
private PaginationOptions<MyParameters> Create(MyParameters parameters, int max) { return new PaginationOptions<MyParameters>(parameters, max); }
public void InitializeSecurityTokenParameters () { MyParameters tp = new MyParameters (); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement (); tp.InitRequirement (r); Assert.AreEqual (ServiceModelSecurityTokenTypes.AnonymousSslnego, r.TokenType, "#1"); Assert.AreEqual (false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2"); SslSecurityTokenParameters dummy; Assert.IsTrue (r.TryGetProperty<SslSecurityTokenParameters> (ReqType.IssuedSecurityTokenParametersProperty, out dummy), "#3"); }
public void ToQueryString() { var p = new MyParameters(); p.Query = "test"; p.Options = new[] {"o1", "o2"}; p.Numbers = new[] {1, 5}; p.Doubles = new[] { 2.3, 17.5 }; p.Latitude = -53.1; p.Longitude = -3; p.Location = GeoPoint.TryCreate(-53.1, -3); var nvc = QueryStringParser<MyParameters>.Parse(p); nvc.Count.Should().Be(7); foreach (var item in nvc.AllKeys) { Console.WriteLine($"{item} => {nvc.Get(item)}"); } Console.WriteLine(nvc); }
public void DefaultValues () { MyParameters p = new MyParameters (); Assert.IsNull (p.BootstrapSecurityBindingElement, "#1-1"); Assert.IsNotNull (p.BootstrapProtectionRequirements, "#1-2"); Assert.AreEqual (true, p.RequireCancellation, "#1-3"); Assert.AreEqual (false, p.Asym, "#1-4"); // they cause NRE on winfx, likely a bug. //Assert.AreEqual (true, p.Client, "#1-5"); //Assert.AreEqual (true, p.Win, "#1-6"); //Assert.AreEqual (true, p.Server, "#1-7"); p = new MyParameters (new AsymmetricSecurityBindingElement ()); Assert.IsNotNull (p.BootstrapSecurityBindingElement, "#2-1"); Assert.IsNotNull (p.BootstrapProtectionRequirements, "#2-2"); Assert.AreEqual (true, p.RequireCancellation, "#2-3"); Assert.AreEqual (false, p.Asym, "#2-4"); // regardless of binding element. Assert.AreEqual (false, p.Client, "#2-5"); Assert.AreEqual (false, p.Win, "#2-6"); Assert.AreEqual (false, p.Server, "#2-7"); ChannelProtectionRequirements r = p.BootstrapProtectionRequirements; Assert.IsTrue (r.IncomingSignatureParts.ChannelParts.IsBodyIncluded, "#3-1"); Assert.IsTrue (r.OutgoingSignatureParts.ChannelParts.IsBodyIncluded, "#3-2"); Assert.IsTrue (r.IncomingEncryptionParts.ChannelParts.IsBodyIncluded, "#3-3"); Assert.IsTrue (r.OutgoingEncryptionParts.ChannelParts.IsBodyIncluded, "#3-4"); }
public void CreateProviderNoIssuerBindingContext () { MyParameters tp = new MyParameters (); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement (); tp.InitRequirement (r); r.TargetAddress = new EndpointAddress ("http://localhost:8080"); r.SecurityBindingElement = new SymmetricSecurityBindingElement (); ClientCredentials cred = new ClientCredentials (); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager (cred); //SecurityTokenProvider p = manager.CreateSecurityTokenProvider (r); }
public void CreateAuthenticator () { MyParameters tp = new MyParameters (); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement (); tp.InitRequirement (r); ClientCredentials cred = new ClientCredentials (); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager (cred); SecurityTokenResolver resolver; // SecurityTokenAuthenticator authenticator = manager.CreateSecurityTokenAuthenticator (r, out resolver); }
private PaginationOptions <MyParameters> Create(MyParameters parameters, int max) { return(new PaginationOptions <MyParameters>(parameters, max)); }
void CreateRecipientProviderCore (bool mutual) { MyParameters tp = new MyParameters (); tp.RequireClientCertificate = true; RecipientServiceModelSecurityTokenRequirement r = new RecipientServiceModelSecurityTokenRequirement (); tp.InitRequirement (r); r.ListenUri = new Uri ("http://localhost:8080"); r.SecurityBindingElement = new SymmetricSecurityBindingElement (); r.Properties [ReqType.IssuerBindingContextProperty] = new BindingContext (new CustomBinding (), new BindingParameterCollection ()); r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion; ClientCredentials cred = new ClientCredentials (); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager (cred); manager.CreateSecurityTokenProvider (r); }
public void CreateProviderNoTargetAddress () { MyParameters tp = new MyParameters (); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement (); tp.InitRequirement (r); ClientCredentials cred = new ClientCredentials (); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager (cred); manager.CreateSecurityTokenProvider (r); }
public ParametersContext() { _parameters = new MyParameters(); _parameters.ContentType = new[] { "test", "test2" }; _parameters.Type = new[] {EnumTypeOptions.OptionOne, EnumTypeOptions.OptionTwo, }; }
void CreateProviderOpenGetToken (bool getToken) { MyParameters tp = new MyParameters (); InitiatorServiceModelSecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement (); tp.InitRequirement (r); r.TargetAddress = new EndpointAddress ("http://localhost:8080"); r.SecurityBindingElement = new SymmetricSecurityBindingElement (); r.Properties [ReqType.IssuerBindingContextProperty] = new BindingContext (new CustomBinding (new HttpTransportBindingElement ()), new BindingParameterCollection ()); r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion; // This is required at GetToken(). r.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default; ClientCredentials cred = new ClientCredentials (); ClientCredentialsSecurityTokenManager manager = new ClientCredentialsSecurityTokenManager (cred); // TLS negotiation token provider is created. SecurityTokenProvider p = manager.CreateSecurityTokenProvider (r); ((ICommunicationObject) p).Open (); if (!getToken) return; p.GetToken (TimeSpan.FromSeconds (5)); }