Esempio n. 1
0
        public async Task CanRegisterWithRestrictionOptions()
        {
            var options = new
            {
                Count = new[] { "Kane" }
            };

            var accessRules = new User.UserAccessRules
            {
                EndDate   = 1414230242338,
                StartDate = 1413315622096,
                Options   = options
            };
            var response = await _controller.Register(new Credentials("*****@*****.**", "aA123456!", null)
            {
                AccessRules = accessRules,
                Agency      = "Agency",
                First       = "First",
                Last        = "Last"
            });

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Created));

            using (var s = DocumentStore.OpenSession())
            {
                var user = s.Query <User, UserByEmailIndex>()
                           .Customize(x => x.WaitForNonStaleResults())
                           .Single(x => x.Email == "*****@*****.**");

                var actual   = JsonConvert.SerializeObject(user.AccessRules);
                var expected = JsonConvert.SerializeObject(accessRules);

                Assert.That(actual, Is.EqualTo(expected));
            }
        }
Esempio n. 2
0
        public async Task CanRegisterWithCustomEmailAndRestictions()
        {
            // county cann't be shown since it's an array.
            using (var s = DocumentStore.OpenSession())
            {
                var config = s.Load <Config>("1");
                config.CustomEmails = new CustomEmails
                {
                    NotifyAdminOfNewUser =
                        "******" +
                        " some administrative actions on a person that has just requested access to a site" +
                        " that you manage.\n\n**{{User.FullName}}**, _({{User.Email}})_, from" +
                        " **{{User.Agency}}** has requested access to {{User.AccessRules.Options.County}} for " +
                        "the **{{Config.Description}}** starting from {{User.AccessRules.PrettyStartDate}} through " +
                        "{{User.AccessRules.PrettyEndDate}}.\n\n" +
                        "We need you to make sure that {{User.First}} should be allowed to access this " +
                        "website _and_ data. You will be able to **accept** {{User.First}} into their appropriate role " +
                        "and restrict {{User.First}}'s access to protected data or **reject** {{User.First}}'s " +
                        "request from the [user administration page]({{Config.BaseUrl}}{{Config.adminUrl}})." +
                        "\n\nThank you and enjoy the rest of your day!\n\n" +
                        "_An email will be sent to all of the other administrators after you perform one " +
                        "of these actions._"
                };

                s.SaveChanges();
            }
            var options = new
            {
                County = new[] { "Kane, Salt Lake" }
            };

            var accessRules = new User.UserAccessRules
            {
                EndDate   = 1414230242338,
                StartDate = 1413315622096,
                Options   = options
            };
            var response = await _controller.Register(new Credentials("*****@*****.**", "aA123456!", null)
            {
                AccessRules = accessRules,
                Agency      = "Agency",
                First       = "First",
                Last        = "Last"
            });

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Created));
        }