Пример #1
0
        private void PrepareTestUrlAcl(NetShHelper sut, string testUrl)
        {
            var createResult = sut.CreateUrlAcl(testUrl);

            if (createResult == false)
            {
                sut.DeleteUrlAcl(testUrl).Should().BeTrue();
                createResult = sut.CreateUrlAcl(testUrl);
            }

            createResult.Should().BeTrue();
        }
Пример #2
0
        public void ShouldBeAbleToCreateUrlAcl()
        {
            Skip.If(!PermissionsHelper.IsRunAsAdministrator(), "require administrator permissions");
            var sut = new NetShHelper();

            var result = sut.CreateUrlAcl(TestUrls[0]);

            result.Should().BeTrue();
        }
Пример #3
0
        public void ShouldFailIfPermissionsRequired()
        {
            Skip.If(PermissionsHelper.IsRunAsAdministrator(), "require non-administrator permissions");

            var sut = new NetShHelper();

            var result = sut.CreateUrlAcl(TestUrls[3]);

            result.Should().BeFalse();
        }
Пример #4
0
        private void SetUrlAcl()
        {
            var uriBuilder = new UriBuilder(new Uri(_baseAddress))
            {
                Host = "+"
            };
            var baseAddress = uriBuilder.ToString();

            var urlReservations = _netShHelper.GetUrlAcl(baseAddress);

            if (!urlReservations.Reservations.Any())
            {
                var result = _netShHelper.CreateUrlAcl(baseAddress);
                if (!result)
                {
                    MessageBox.Show(
                        $"Sorry, {GeneralInformation.ApplicationName} cannot add URL reservation. Please allow next time or try to run as Administrator.",
                        $"{GeneralInformation.ApplicationName} can't start service.",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information);
                }
            }
        }