Ejemplo n.º 1
0
        public void ThenICanNotExecuteProtectedAdminMethodsWithInsufficientPermissions()
        {
            LogWithNewUser(Modules.VipLevelManager, Permissions.View);

            const int statusCode = (int)HttpStatusCode.Forbidden;

            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.SaveCountry(new EditCountryData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.DeleteCountry(new DeleteCountryData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.ActivateCulture(new ActivateCultureData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.DeactivateCulture(new DeactivateCultureData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.SaveCulture(new EditCultureData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.ActivateCurrency(new ActivateCurrencyData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.DeactivateCulture(new DeactivateCultureData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.SaveCurrency(new EditCurrencyData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.CreateUserInAdminManager(new AddAdminData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.UpdateUserInAdminManager(new EditAdminData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.ResetPasswordInAdminManager(new AddAdminData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.ActivateUserInAdminManager(new ActivateUserData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.DeactivateUserInAdminManager(new DeactivateUserData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.GetLicenseeDataInAdminManager(new GetLicenseeData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.CreateRoleInRoleManager(new AddRoleData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.UpdateRoleInRoleManager(new EditRoleData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.GetLicenseeDataInRoleManager(new List <Guid>())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.CreateSettingInIdentificationDocumentSettings(new IdentificationDocumentSettingsData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.UpdateSettingInIdentificationDocumentSettings(new IdentificationDocumentSettingsData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.CreateIpRegulationInAdminIpRegulations(new EditAdminIpRegulationData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.UpdateIpRegulationInAdminIpRegulations(new EditAdminIpRegulationData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.DeleteIpRegulationInAdminIpRegulations(new DeleteAdminIpRegulationData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.CreateIpRegulationInBrandIpRegulations(new AddBrandIpRegulationData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.UpdateIpRegulationInBrandIpRegulations(new RegoV2.Core.Common.Data.Admin.EditBrandIpRegulationData())).GetHttpCode(), Is.EqualTo(statusCode));
            Assert.That(Assert.Throws <HttpException>(() => AdminApiProxy.DeleteIpRegulationInBrandIpRegulations(new DeleteBrandIpRegulationData())).GetHttpCode(), Is.EqualTo(statusCode));
        }
Ejemplo n.º 2
0
        public void ThenNewRoleIsSuccessfullyCreated()
        {
            ScenarioContext.Current.Should().ContainKey("licenseeId");
            var licenseeId = ScenarioContext.Current.Get <Guid>("licenseeId");

            var data = new AddRoleData
            {
                Code               = "Role-" + TestDataGenerator.GetRandomString(5),
                Name               = "Role-" + TestDataGenerator.GetRandomString(5),
                Description        = TestDataGenerator.GetRandomString(),
                AssignedLicensees  = new[] { licenseeId },
                CheckedPermissions = Container.Resolve <IAuthQueries>().GetPermissions().Select(p => p.Id).ToList()
            };

            var result = AdminApiProxy.CreateRoleInRoleManager(data);

            result.Should().NotBeNull();
            result.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK);
        }