public void CanAttachCTLToSSLInfo() { var testEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2924); CTLContextBuilder builder = new CTLContextBuilder(); builder.CTLInfo.ListIdentifier = "my test list binding"; builder.CTLInfo.Certificates.Add(Verisign); builder.CTLInfo.Certificates.Add(KisaRoot1); builder.Signers.Add(TestCertificate); HttpAPIManager manager = new HttpAPIManager(); var context = builder.ToCTLContext(); try { context.ImportInStore(StoreLocation.LocalMachine, StoreName.Root); SSLInfo info = new SSLInfo(); info.CheckClientCertificate = false; info.NegotiateClientCert = true; info.CTLIdentifier = context.CTLInfo.ListIdentifier; info.CTLStoreName = StoreName.Root; info.Certificate = TestCertificate; manager.SetSSLInfo(testEndpoint, info); } finally { context.RemoveFromStore(StoreLocation.LocalMachine, StoreName.Root); manager.RemoveSSLInfo(testEndpoint); } }
public TestAcl() { _Url = "http://+:9393/"; HttpAPIManager manager = new HttpAPIManager(); manager.SetUrlAcl(_Url, SecurityDescriptor.FromSDDL("D:(A;;GX;;;WD)")); }
public void CanListCertificates() { var testEndpoints = new[] { new IPEndPoint(IPAddress.Parse("127.0.0.1"), 462), new IPEndPoint(IPAddress.Parse("127.0.0.2"), 462) }; HttpAPIManager manager = new HttpAPIManager(); var oldSslCount = manager.GetSSLInfos().Count(); try { foreach (var endpoint in testEndpoints) { manager.SetSSLInfo(endpoint, new SSLInfo(TestCertificate.Thumbprint)); } var newSslCount = manager.GetSSLInfos().Count(); Assert.Equal(oldSslCount + testEndpoints.Length, newSslCount); } finally { foreach (var endpoint in testEndpoints) { manager.RemoveSSLInfo(endpoint); } } }
public override void Execute(object parameter) { ViewModel.NewAcl = WithPort(WithTrailingSlash(ViewModel.NewAcl)); var manager = new HttpAPIManager(); manager.SetUrlAcl(ViewModel.NewAcl, MainWindowViewModel.CreateAllRightsToCurrentUser()); ViewModel.Acls.Insert(0, manager.GetAclInfo(ViewModel.NewAcl)); ViewModel.NewAcl = ""; }
public void CanSetUrlTwiceAndSetToNullToRemove() { var testUrl = "http://+:9394/"; HttpAPIManager manager = new HttpAPIManager(); manager.SetUrlAcl(testUrl, SecurityDescriptor.FromSDDL("D:(A;;GX;;;WD)")); manager.SetUrlAcl(testUrl, SecurityDescriptor.FromSDDL("D:(A;;;;;WD)")); Assert.Equal("D:(A;;;;;WD)", manager.GetAclInfo(testUrl).SecurityDescriptor.ToString()); manager.SetUrlAcl(testUrl, null); Assert.Null(manager.GetAclInfo(testUrl)); }
public void CanQueryAcls() { HttpAPIManager manager = new HttpAPIManager(); var testUrl = "http://+:9399/CanQueryAclsTest"; manager.SetUrlAcl(testUrl, SecurityDescriptor.FromSDDL("D:(A;;;;;WD)")); try { var containsTemporaryUrl = manager.GetAclInfo().Any(url => url.Prefix.Contains("CanQueryAclsTest")); Assert.True(containsTemporaryUrl, "You should be able to retrieve Acls"); } finally { manager.RemoveUrlAcl(testUrl); } }
public void CanSetCertificates() { var testEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 462); HttpAPIManager manager = new HttpAPIManager(); manager.SetSSLInfo(testEndpoint, new SSLInfo(TestCertificate.Thumbprint)); try { var sslInfo = manager.GetSSLInfo(testEndpoint); Assert.NotNull(sslInfo); Assert.Equal(TestCertificate.Thumbprint, sslInfo.Certificate.Thumbprint); } finally { manager.RemoveSSLInfo(testEndpoint); var sslInfo = manager.GetSSLInfo(testEndpoint); Assert.Null(sslInfo); } }
public void CanAddAndRemoveAcl() { var testUrl = "http://+:9393/"; HttpAPIManager manager = new HttpAPIManager(); manager.SetUrlAcl(testUrl, SecurityDescriptor.FromSDDL("D:(A;;GX;;;WD)")); try { var acl = manager.GetAclInfo(testUrl); Assert.NotNull(acl); var fakeAcl = manager.GetAclInfo("unknown"); Assert.Null(fakeAcl); } finally { manager.RemoveUrlAcl(testUrl); } var oldAcl = manager.GetAclInfo(testUrl); Assert.Null(oldAcl); }
public void CanSetSSLInfoTwiceAndSetToNullToRemove() { var testEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 464); var info = new SSLInfo(TestCertificate.Thumbprint); HttpAPIManager manager = new HttpAPIManager(); manager.SetSSLInfo(testEndpoint, info); try { Assert.NotNull(manager.GetSSLInfo(testEndpoint)); Assert.Equal(false, manager.GetSSLInfo(testEndpoint).NegotiateClientCert); info.NegotiateClientCert = true; manager.SetSSLInfo(testEndpoint, info); Assert.NotNull(manager.GetSSLInfo(testEndpoint)); Assert.Equal(true, manager.GetSSLInfo(testEndpoint).NegotiateClientCert); } finally { manager.SetSSLInfo(testEndpoint, null); Assert.Null(manager.GetSSLInfo(testEndpoint)); } }
public void Dispose() { HttpAPIManager manager = new HttpAPIManager(); manager.RemoveUrlAcl(_Url); }