public void Then_Uses_Unapproved_Add_Apprentice_For_Select_Journey_With_Empty_Cohort(
            Guid reservationId,
            string accountLegalEntityPublicHashedId,
            string accountHashedId,
            string courseId,
            uint ukPrn,
            DateTime startDate,
            [Frozen] ReservationsWebConfiguration webConfig,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("employer");

            var originalConfigUrl = webConfig.EmployerApprenticeUrl;

            webConfig.EmployerApprenticeUrl = $"https://{webConfig.EmployerApprenticeUrl}";

            var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId,
                                                               accountLegalEntityPublicHashedId,
                                                               courseId,
                                                               ukPrn,
                                                               startDate,
                                                               "",
                                                               accountHashedId,
                                                               true);

            Assert.AreEqual(
                $"https://{originalConfigUrl}/{accountHashedId}/unapproved/add/apprentice?reservationId={reservationId}&accountLegalEntityHashedId={accountLegalEntityPublicHashedId}&providerId={ukPrn}&startMonthYear={startDate:MMyyyy}&courseCode={courseId}",
                actualUrl);
        }
Example #2
0
        public void Then_The_Folder_Is_Included_In_The_Url_And_Correct_Base_Url_Based_On_Auth_Type()
        {
            //Arrange
            var controller = "test-controller";
            var subDomain  = "testDomain";
            var folder     = "test-folder";

            _reservationsConfig = new Mock <IOptions <ReservationsWebConfiguration> >();
            _reservationsConfig.Setup(x => x.Value.DashboardUrl).Returns("https://test.local/account");
            _reservationsConfig.Setup(x => x.Value.EmployerDashboardUrl).Returns("https://test.local.dashboard/");
            _config = new Mock <IConfiguration>();
            _config.Setup(x => x["AuthType"]).Returns("employer");
            _helper = new ExternalUrlHelper(_reservationsConfig.Object, _config.Object);

            //Act
            var actual = _helper.GenerateUrl(new UrlParameters {
                Controller = controller,
                SubDomain  = subDomain,
                Folder     = folder
            });

            //Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual($"https://{subDomain}.test.local.dashboard/{folder}/{controller}", actual);
        }
        public void Then_CourseCode_And_StartDate_Are_Not_Added_To_Query_String_If_Not_Supplied(
            Guid reservationId,
            string accountLegalEntityPublicHashedId,
            uint ukPrn,
            [Frozen] ReservationsWebConfiguration webConfig,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("provider");

            var originalConfigUrl = webConfig.ApprenticeUrl;

            webConfig.ApprenticeUrl = $"https://{webConfig.ApprenticeUrl}";

            var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId,
                                                               accountLegalEntityPublicHashedId,
                                                               "",
                                                               ukPrn,
                                                               null,
                                                               "",
                                                               "");

            Assert.AreEqual(
                $"https://{originalConfigUrl}/{ukPrn}/unapproved/add/apprentice?reservationId={reservationId}&employerAccountLegalEntityPublicHashedId={accountLegalEntityPublicHashedId}&autocreated=true",
                actualUrl);
        }
        public void Then_Uses_Unapproved_Controller_With_Cohort_Ref_When_There_Is_A_Cohort_Ref(
            Guid reservationId,
            string accountLegalEntityPublicHashedId,
            string courseId,
            uint ukPrn,
            DateTime startDate,
            string cohortRef,
            [Frozen] ReservationsWebConfiguration webConfig,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("provider");

            var originalConfigUrl = webConfig.ApprenticeUrl;

            webConfig.ApprenticeUrl = $"https://{webConfig.ApprenticeUrl}";

            var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId,
                                                               accountLegalEntityPublicHashedId,
                                                               courseId,
                                                               ukPrn,
                                                               startDate,
                                                               cohortRef,
                                                               "");

            Assert.AreEqual(
                $"https://{originalConfigUrl}/{ukPrn}/unapproved/{cohortRef}/apprentices/add?reservationId={reservationId}&employerAccountLegalEntityPublicHashedId={accountLegalEntityPublicHashedId}&startMonthYear={startDate:MMyyyy}&courseCode={courseId}",
                actualUrl);
        }
        public void Then_adds_levy_flag_To_query_string_if_no_course_or_start_date_provided(
            Guid reservationId,
            string accountLegalEntityPublicHashedId,
            string accountHashedId,
            [Frozen] ReservationsWebConfiguration webConfig,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("employer");

            var originalConfigUrl = webConfig.EmployerApprenticeUrl;

            webConfig.EmployerApprenticeUrl = $"https://{webConfig.EmployerApprenticeUrl}";

            var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId,
                                                               accountLegalEntityPublicHashedId,
                                                               "",
                                                               null,
                                                               null,
                                                               "",
                                                               accountHashedId);

            Assert.AreEqual(
                $"https://{originalConfigUrl}/{accountHashedId}/unapproved/add?reservationId={reservationId}&accountLegalEntityHashedId={accountLegalEntityPublicHashedId}&autocreated=true",
                actualUrl);
        }
Example #6
0
        public void Then_Adds_The_TransferSenderId_If_It_Has_Been_Provided(
            Guid reservationId,
            string accountLegalEntityPublicHashedId,
            string courseId,
            string transferSenderId,
            uint ukPrn,
            DateTime startDate,
            [Frozen] ReservationsWebConfiguration webConfig,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("provider");

            var originalConfigUrl = webConfig.ApprenticeUrl;

            webConfig.ApprenticeUrl = $"https://{webConfig.ApprenticeUrl}";

            var actualUrl = urlHelper.GenerateAddApprenticeUrl(reservationId,
                                                               accountLegalEntityPublicHashedId,
                                                               courseId,
                                                               ukPrn,
                                                               startDate,
                                                               "",
                                                               "",
                                                               false,
                                                               transferSenderId);

            Assert.AreEqual(
                $"https://{originalConfigUrl}/{ukPrn}/unapproved/add/apprentice?reservationId={reservationId}&employerAccountLegalEntityPublicHashedId={accountLegalEntityPublicHashedId}&startMonthYear={startDate:MMyyyy}&courseCode={courseId}&transferSenderId={transferSenderId}",
                actualUrl);
        }
Example #7
0
 public void Arrange()
 {
     _reservationsConfig = new Mock <IOptions <ReservationsWebConfiguration> >();
     _reservationsConfig.Setup(x => x.Value.DashboardUrl).Returns("https://test.local");
     _config = new Mock <IConfiguration>();
     _config.Setup(x => x["AuthType"]).Returns("provider");
     _helper = new ExternalUrlHelper(_reservationsConfig.Object, _config.Object);
 }
Example #8
0
        public void Then_Uses_ProviderUrl_And_Params_To_Build_Employer_Url(
            [Frozen] ReservationsWebConfiguration webConfig,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("provider");

            webConfig.DashboardUrl = $"https://{webConfig.DashboardUrl}";

            var actualUrl = urlHelper.GenerateDashboardUrl();

            Assert.AreEqual(
                $"{webConfig.DashboardUrl}/Account", actualUrl);
        }
Example #9
0
        public void Then_Takes_You_Unapproved_Add_Assign_When_There_Is_No_CohortRef(
            string accountId,
            [Frozen] ReservationsWebConfiguration options,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("employer");
            options.EmployerDashboardUrl = $"https://{options.EmployerDashboardUrl}";

            var actualUrl = urlHelper.GenerateCohortDetailsUrl(null, accountId, "");

            Assert.AreEqual(
                $"{options.EmployerDashboardUrl}/commitments/accounts/{accountId}/unapproved/add/assign",
                actualUrl);
        }
Example #10
0
        public void Then_Uses_Folder_When_There_Is_A_Ukprn_And_Is_Empty_Cohort_Journey(
            string accountId,
            uint ukprn,
            [Frozen] ReservationsWebConfiguration options,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("employer");
            options.EmployerDashboardUrl = $"https://{options.EmployerDashboardUrl}";

            var actualUrl = urlHelper.GenerateCohortDetailsUrl(ukprn, accountId, string.Empty, true);

            Assert.AreEqual(
                $"{options.EmployerDashboardUrl}/commitments/accounts/{accountId}/unapproved/add?providerId={ukprn}",
                actualUrl);
        }
Example #11
0
        public void Then_Uses_Folder_When_There_Is_No_Ukprn(
            string accountId,
            string cohortRef,
            [Frozen] ReservationsWebConfiguration options,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("employer");
            options.EmployerDashboardUrl = $"https://{options.EmployerDashboardUrl}";

            var actualUrl = urlHelper.GenerateCohortDetailsUrl(null, accountId, cohortRef);

            Assert.AreEqual(
                $"{options.EmployerDashboardUrl}/commitments/accounts/{accountId}/apprentices/{cohortRef}/details",
                actualUrl);
        }
Example #12
0
        public void Then_Uses_No_Folder_When_There_Is_A_Ukprn(
            uint ukprn,
            string cohortRef,
            [Frozen] ReservationsWebConfiguration options,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("provider");
            options.DashboardUrl = $"https://{options.DashboardUrl}";

            var actualUrl = urlHelper.GenerateCohortDetailsUrl(ukprn, "", cohortRef);

            Assert.AreEqual(
                $"{options.DashboardUrl}/{ukprn}/apprentices/{cohortRef}/details",
                actualUrl);
        }
        public void Then_Uses_EmployerApprenticeUrl_And_Params_To_Build_Employer_Url(
            UrlParameters urlParameters,
            [Frozen] ReservationsWebConfiguration webConfig,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("employer");

            var originalConfigUrl = webConfig.EmployerApprenticeUrl;

            webConfig.EmployerApprenticeUrl = $"https://{webConfig.EmployerApprenticeUrl}";

            var actualUrl = urlHelper.GenerateAddApprenticeUrl(urlParameters);

            Assert.AreEqual(
                $"https://{urlParameters.SubDomain}.{originalConfigUrl}/{urlParameters.Folder}/{urlParameters.Id}/{urlParameters.Controller}/{urlParameters.Action}{urlParameters.QueryString}",
                actualUrl);
        }
Example #14
0
        public void Then_Uses_EmployerUrl_And_Params_To_Build_Employer_Url(
            string accountId,
            [Frozen] ReservationsWebConfiguration webConfig,
            [Frozen] Mock <IConfiguration> config,
            ExternalUrlHelper urlHelper)
        {
            config.Setup(x => x["AuthType"]).Returns("employer");

            var originalConfigUrl = webConfig.EmployerDashboardUrl;

            webConfig.EmployerDashboardUrl = $"https://{webConfig.EmployerDashboardUrl}";

            var actualUrl = urlHelper.GenerateDashboardUrl(accountId);

            Assert.AreEqual(
                $"https://accounts.{originalConfigUrl}/accounts/{accountId}/teams",
                actualUrl);
        }