Exemplo n.º 1
0
        public void Cannot_execute_BackendIpRegulationService_without_permissions()
        {
            /* Arrange */
            LogWithNewAdmin(Modules.PlayerManager, Permissions.View);

            /* Act */
            Assert.Throws <InsufficientPermissionsException>(() => _brandService.GetIpRegulations());
            Assert.Throws <InsufficientPermissionsException>(() => _brandService.CreateIpRegulation(new AddBrandIpRegulationData()));
            Assert.Throws <InsufficientPermissionsException>(() => _brandService.UpdateIpRegulation(new EditBrandIpRegulationData()));
            Assert.Throws <InsufficientPermissionsException>(() => _brandService.DeleteIpRegulation(new Guid()));
        }
Exemplo n.º 2
0
        private void AddBrandIpRegulations(Guid licenseeId, Guid brandId, string ipAddress, string redirectionUrl)
        {
            var regulation = _securityRepository.BrandIpRegulations.FirstOrDefault(x => x.IpAddress == ipAddress && x.BrandId == brandId);

            if (regulation != null)
            {
                return;
            }

            _brandIpRegulationService.CreateIpRegulation(new AddBrandIpRegulationData()
            {
                LicenseeId     = licenseeId,
                BrandId        = brandId,
                BlockingType   = IpRegulationConstants.BlockingTypes.Redirection, // Ip address is blocked with redirection to specified Url
                RedirectionUrl = redirectionUrl,
                IpAddress      = ipAddress,
                Description    = "test"
            });
        }
Exemplo n.º 3
0
        public BrandIpRegulation CreateBrandIpRegulation(string ipAddress, string brandName,
                                                         string redirectUrl = null, string blockingType = null)
        {
            var brand = _brandQueries.GetBrands().SingleOrDefault(b => b.Name == brandName);

            if (brand == null)
            {
                throw new RegoValidationException(SecurityErrorCodes.InvalidBrandCode.ToString());
            }

            var addIpRegulationData = new AddBrandIpRegulationData
            {
                IpAddress      = ipAddress,
                LicenseeId     = brand.LicenseeId,
                BrandId        = brand.Id,
                RedirectionUrl = redirectUrl,
                BlockingType   = blockingType
            };

            return(_brandIpRegulationService.CreateIpRegulation(addIpRegulationData));
        }
        public void Can_create_brand_ip_regulation()
        {
            /*** Arrange ***/
            var ipAddress = TestDataGenerator.GetRandomIpAddress();

            const string redirectionUrl = "google.com";

            var brandIpRegulation = new AddBrandIpRegulationData
            {
                IpAddress = ipAddress,
                BrandId   = Brand.Id,
                // Ip address is blocked with redirection to specified Url
                BlockingType   = IpRegulationConstants.BlockingTypes.Redirection,
                RedirectionUrl = redirectionUrl
            };

            /*** Act ***/
            _brandService.CreateIpRegulation(brandIpRegulation);

            /*** Assert ***/
            var regulation = _brandService.GetIpRegulations().SingleOrDefault(ip => ip.IpAddress == ipAddress);

            Assert.IsNotNull(regulation);
        }