예제 #1
0
        public void TestLogInReturnUrl()
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            Assert.IsNull(_linkedInQuery.GetProfile(LinkedInId));
            Assert.IsNull(_linkedInQuery.GetProfile(employer.Id));

            Get(HomeUrl);
            var anonymousId = GetAnonymousId();

            // Redirected to login page.

            Get(_settingsUrl);
            var loginUrl = EmployerLogInUrl.AsNonReadOnly();

            loginUrl.QueryString["returnUrl"] = _settingsUrl.PathAndQuery;
            AssertUrl(loginUrl);
            AssertAutoAuthorize(false);

            // Log in.

            var url        = LinkedInApiLogIn(AuthenticationStatus.Failed, CreateApiProfile());
            var accountUrl = _accountUrl.AsNonReadOnly();

            accountUrl.QueryString["returnUrl"] = _settingsUrl.PathAndQuery;
            Assert.AreEqual(accountUrl.PathAndQuery.ToLower(), url.PathAndQuery.ToLower());

            // Profile should be created for the anonymous user.

            var profile = CreateProfile();

            profile.UserId = anonymousId;
            AssertProfile(profile, _linkedInQuery.GetProfile(LinkedInId));
            Assert.IsNull(_linkedInQuery.GetProfile(employer.Id));

            // Confirm.

            Get(url);
            AssertUrl(accountUrl);

            SubmitLogIn(employer);
            AssertUrl(_settingsUrl);

            // Should now be associated with the employer.

            profile.UserId = employer.Id;
            AssertProfile(profile, _linkedInQuery.GetProfile(LinkedInId));
            AssertProfile(profile, _linkedInQuery.GetProfile(employer.Id));

            // Logout.

            LogOut();
            AssertUrl(EmployerHomeUrl);
            AssertAutoAuthorize(true);

            Get(EmployerLogInUrl);
            AssertAutoAuthorize(true);
        }
예제 #2
0
        public void TestAutoLogInReturnUrl()
        {
            var profile  = CreateProfile();
            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            profile.UserId = employer.Id;
            _linkedInCommand.UpdateProfile(profile);

            // Redirected to login page.

            Get(_settingsUrl);
            var loginUrl = EmployerLogInUrl.AsNonReadOnly();

            loginUrl.QueryString["returnUrl"] = _settingsUrl.PathAndQuery;
            AssertUrl(loginUrl);
            AssertAutoAuthorize(false);

            // Login.

            var url = LinkedInApiLogIn(AuthenticationStatus.Authenticated, CreateApiProfile());

            Assert.AreEqual(_settingsUrl.PathAndQuery.ToLower(), url.PathAndQuery.ToLower());

            // Confirm logged in.

            Get(url);
            AssertUrl(_settingsUrl);

            // Profile should not have changed.

            AssertProfile(profile, _linkedInQuery.GetProfile(LinkedInId));
            AssertProfile(profile, _linkedInQuery.GetProfile(employer.Id));

            // Logout.

            LogOut();
            AssertUrl(EmployerHomeUrl);
            AssertAutoAuthorize(true);

            Get(EmployerLogInUrl);
            AssertAutoAuthorize(true);
        }
예제 #3
0
        public void TestEmployerNewsletterEmailLinks()
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            // Send the email.

            _emailsCommand.TrySend(new EmployerNewsletterEmail(employer));
            _settingsCommand.SetLastSentTime(employer.Id, _settingsQuery.GetDefinition("EmployerNewsletterEmail").Id, null);

            // Check the email.

            var email = _emailServer.AssertEmailSent();
            var links = GetUpdateLinks(email.GetHtmlView().Body);

            Assert.AreEqual(8, links.Count);

            var definition = typeof(EmployerNewsletterEmail).Name;

            var currentLink = 0;
            var url         = EmployerLogInUrl.AsNonReadOnly();

            url.QueryString["userId"] = employer.GetLoginId();
            AssertLink(definition, url, links[currentLink++]);

            // These 3 links are search, create alert, create a saved search.

            AssertLink(definition, _candidateSearchUrl, links[currentLink++]);
            AssertLink(definition, _candidateSearchUrl, links[currentLink++]);
            AssertLink(definition, _candidateSearchUrl, links[currentLink++]);
            AssertLink(definition, _employerNewJobAdUrl, links[currentLink++]);

            AssertLink(definition, HomeUrl, links[currentLink++]);
            AssertLink(definition, employer, _employerSettingsUrl, links[currentLink++]);
            AssertLink(definition, GetUnsubscribeUrl(employer.Id.ToString(), "EmployerUpdate"), links[currentLink]);

            // Check the tracking pixel.

            var link = GetUpdateImageLinks(email.GetHtmlView().Body).Last();

            AssertTrackingLink(link);
        }
예제 #4
0
        public void TestJoinReturnUrl()
        {
            Assert.IsNull(_linkedInQuery.GetProfile(LinkedInId));

            Get(HomeUrl);
            var anonymousId = GetAnonymousId();

            // Redirected to login page.

            Get(_settingsUrl);
            var loginUrl = EmployerLogInUrl.AsNonReadOnly();

            loginUrl.QueryString["returnUrl"] = _settingsUrl.PathAndQuery;
            AssertUrl(loginUrl);
            AssertAutoAuthorize(false);

            // Log in.

            var url        = LinkedInApiLogIn(AuthenticationStatus.Failed, CreateApiProfile());
            var accountUrl = _accountUrl.AsNonReadOnly();

            accountUrl.QueryString["returnUrl"] = _settingsUrl.PathAndQuery;
            Assert.AreEqual(accountUrl.PathAndQuery.ToLower(), url.PathAndQuery.ToLower());

            // Profile should be created for the anonymous user.

            var profile = CreateProfile();

            profile.UserId = anonymousId;
            AssertProfile(profile, _linkedInQuery.GetProfile(LinkedInId));

            // Confirm.

            Get(url);
            AssertUrl(accountUrl);

            // Check the screen is populated.

            Assert.AreEqual(_firstNameTextBox.Text, FirstName);
            Assert.AreEqual(_lastNameTextBox.Text, LastName);
            Assert.AreEqual(1, _industryIdsListBox.SelectedItems.Count);
            Assert.AreEqual(_industryIdsListBox.SelectedItems[0].Text, Industry);
            Assert.AreEqual(_locationTextBox.Text, Location);
            Assert.AreEqual(_organisationNameTextBox.Text, OrganisationName);

            Join();
            AssertUrl(_settingsUrl);

            // Should now be associated with the employer.

            var updatedProfile = _linkedInQuery.GetProfile(LinkedInId);
            var employerId     = updatedProfile.UserId;

            profile.UserId = employerId;

            AssertProfile(profile, updatedProfile);
            AssertProfile(profile, _linkedInQuery.GetProfile(employerId));

            // Check the employer account.

            AssertEmployer(_employersQuery.GetEmployer(employerId));

            // Logout.

            LogOut();
            AssertUrl(EmployerHomeUrl);
            AssertAutoAuthorize(true);

            Get(EmployerLogInUrl);
            AssertAutoAuthorize(true);
        }