public async System.Threading.Tasks.Task EventDetailsAsync() { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var apiSetting = new APISettings(configuration); var pbsClient = new PBSClient(); var eventService = new EventService(apiSetting, pbsClient); var memberService = new MemberService(apiSetting, pbsClient); var dateTimeHelper = new DateTimeHelper(); //auto mapper configuration var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new ServiceProfile()); }); var mapper = mockMapper.CreateMapper(); var businessService = new BusinessService(mapper, eventService, memberService, dateTimeHelper); Assert.NotNull(businessService); var eventList = await businessService.GetEventDetailsAsync("2019-05-13", 26788); Assert.NotNull(eventList); Assert.NotEmpty(eventList.Members); Assert.Single(eventList.Members); Assert.Equal("Business Statement", eventList.Category); Assert.Equal("Rt Hon Andrea Leadsom MP", eventList.Members[0].FullTitle); }
public async System.Threading.Tasks.Task EventsAsync() { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var apiSetting = new APISettings(configuration); var pbsClient = new PBSClient(); var eventService = new EventService(apiSetting, pbsClient); var memberService = new MemberService(apiSetting, pbsClient); var dateTimeHelper = new DateTimeHelper(); //auto mapper configuration var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new ServiceProfile()); }); var mapper = mockMapper.CreateMapper(); var businessService = new BusinessService(mapper, eventService, memberService, dateTimeHelper); Assert.NotNull(businessService); var eventList = await businessService.GetEventsAsync("2019-05-11"); Assert.NotNull(eventList); Assert.NotEmpty(eventList); Assert.Equal(0, eventList.Count(x => x.StartDate < new DateTime(2019, 5, 6))); Assert.Equal(0, eventList.Count(x => x.EndDate > new DateTime(2019, 5, 12))); }
public void SetUp() { var apiSettingsWithParameters = new APISettings { Endpoint = this.AppSettings.APIConfig.EndpointBaseUrl.ProfileSearch, QueryParameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("page", "2"), new KeyValuePair <string, string>("pageSize", "15"), }, }; var apiSettingsWithoutParameters = new APISettings { Endpoint = this.AppSettings.APIConfig.EndpointBaseUrl.ProfileSearch }; var tempAppSettings = new AppSettings { APIConfig = new APIConfig { ApimSubscriptionKey = this.CommonAction.RandomString(10), Version = this.AppSettings.APIConfig.Version, }, }; this.authorisedApi = new JobProfileApi(new RestClientFactory(), new RestRequestFactory(), this.AppSettings, apiSettingsWithoutParameters); this.authorisedApiWithQueryParameters = new JobProfileApi(new RestClientFactory(), new RestRequestFactory(), this.AppSettings, apiSettingsWithParameters); this.unauthorisedApi = new JobProfileApi(new RestClientFactory(), new RestRequestFactory(), tempAppSettings, apiSettingsWithoutParameters); }
internal AuthTokenRequest(string clientId, string clientSecret, string code, string redirectUri, APISettings settings) : base(settings) { if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException(); } if (string.IsNullOrEmpty(clientSecret)) { throw new ArgumentNullException(); } if (string.IsNullOrEmpty(code)) { throw new ArgumentNullException(); } if (string.IsNullOrEmpty(redirectUri)) { throw new ArgumentNullException(); } _ClientId = clientId; _ClientSecret = clientSecret; _Code = code; _RedirectUri = redirectUri; }
public void BeforeRequest_RaisesBeforeRequestEvent() { //Setup var newSite = new TargetSiteMock("127.0.0.1") { SetHost = "www.google.com" }; var settings = new APISettings() { DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite }; var request = new GetRequestStub(settings); //Mock crap var restReq = new Mock <IRestRequest>(); var restClient = new Mock <IRestClient>(); restClient.Setup(x => x.BaseUrl).Returns("https://127.0.0.1/Exammple"); request.Request = restReq.Object; request.Client = restClient.Object; //Assert request.OnBeforeRequest += (HandleBeforeRequest); request.RunBeforeGet(); Assert.AreEqual(true, _HasEventFired); request.OnBeforeRequest -= (HandleBeforeRequest); }
public void BeforeRequest_AddsHostParameter() { //Setup var newSite = new TargetSiteMock("127.0.0.1") { SetHost = "www.google.com" }; var settings = new APISettings() { DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite }; var request = new GetRequestStub(settings); //Mock crap var restReq = new Mock <IRestRequest>(); restReq.Setup(x => x.AddHeader("Host", "www.google.com")); var restClient = new Mock <IRestClient>(); request.Request = restReq.Object; request.Client = restClient.Object; //Assert request.RunBeforeGet(); restReq.VerifyAll(); }
public ActionResult APICredentials(APICredentialsModel model, string returnUrl) { if (ModelState.IsValid) { if (APISettings.checkValidCredentials(model)) { Response.AppendCookie(new HttpCookie("username", model.Username)); Response.AppendCookie(new HttpCookie("password", model.Password)); Response.AppendCookie(new HttpCookie("sourceName", model.SourceName)); Response.AppendCookie(new HttpCookie("sourcePassword", model.SourcePassword)); Response.AppendCookie(new HttpCookie("siteID", model.SiteID.ToString())); Response.AppendCookie(new HttpCookie("staffName", model.StaffName)); Response.AppendCookie(new HttpCookie("staffPassword", model.StaffPassword)); return RedirectToAction("Index", "Home"); } ModelState.AddModelError("", "Credentials are Invalid"); } var credentials = new APISettings(); ViewBag.Username = credentials.Username; ViewBag.Password = credentials.Password; ViewBag.SourceName = credentials.SourceName; ViewBag.SourcePassword = credentials.SourcePassword; ViewBag.SiteID = credentials.SiteID; ViewBag.StaffName = credentials.StaffName; ViewBag.StaffPassword = credentials.StaffPassword; // If we got this far, something failed, redisplay form return View(); }
public AccountController(SignInManager <IdentityUser> signInManager, UserManager <IdentityUser> userManager, RoleManager <IdentityRole> roleManager, IOptions <APISettings> options) { _signInManager = signInManager; _userManager = userManager; _roleManager = roleManager; _aPISettings = options.Value; // automaticly retreew all value's for APISettings. }
public async Task <SystemStatus> TestConnectionAsync(APISettings settings) { using (logger.BeginScope("Test Connection")) { if (settings == null || !settings.Ok) { logger.LogDebug("Test aborted, due to insufficient settings"); return(new() { Success = false, ErrorMessage = "Radarr Settings are missing" }); } logger.LogInformation($"Test Radarr Connection."); SystemStatus ss = new(); var link = $"{settings.APIURL}/api/system/status?apikey={settings.APIKey}"; logger.LogDebug($"LinkURL: {link}"); var hc = new HttpClient(); try { logger.LogDebug($"Connecting."); var hrm = await hc.GetAsync(link); var statusJSON = await hrm.Content.ReadAsStringAsync(); if (AppEnvironment.IsDevelopment) { _ = fileService.DumpDebugFile("testConnection.json", statusJSON); } if (hrm.IsSuccessStatusCode) { ss = JsonConvert.DeserializeObject <SystemStatus>(statusJSON); ss.Success = true; logger.LogInformation($"Success."); } else { logger.LogWarning($"Failed: {hrm.StatusCode}"); ss.Success = false; ss.ErrorMessage = $"{hrm.StatusCode}"; if (hrm.ReasonPhrase != hrm.StatusCode.ToString()) { ss.ErrorMessage += $"- {hrm.ReasonPhrase}"; logger.LogWarning($"Failed: {hrm.ReasonPhrase}"); } } } catch (Exception ex) { ss.Success = false; ss.ErrorMessage = $"Request Exception: {ex.Message}"; logger.LogError(ex.ToString()); } return(ss); } }
public ApplyLinkRequest(ApplyLink args, APISettings settings) : base(settings) { if (args == null) { throw new ArgumentException(); } model = args; }
protected PostRequest(APISettings settings) { if (settings == null) { throw new ArgumentNullException("settings", "You must provide valid API settings"); } _Settings = settings; if (_Settings.TargetSite == null) { throw new ArgumentNullException("domain", "Please provide a valid domain name"); } }
public AccountController(SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager, IOptions <APISettings> options) { _roleManager = roleManager; _userManager = userManager; _signInManager = signInManager; _aPISettings = options.Value; }
public AccountController(SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager , IOptions <APISettings> options) { _signInManager = signInManager; _userManager = userManager; _roleManager = roleManager; /* startup.cs 에서 등록한 services.Configure<APISettings>(appSettingSection); APISettings 에 있는 값을 * _apiSettings 에 주입시키는 코드*/ _apiSettings = options.Value; }
public JobRecommendationsWithUserPreferencesRequest(string jobDid, string userDid, APISettings settings) : base(jobDid, settings) { if (string.IsNullOrEmpty(userDid)) { throw new ArgumentNullException(); } if (userDid.Length >= 18 && userDid.Length <= 20 && userDid.StartsWith("U", StringComparison.InvariantCultureIgnoreCase)) { _userDid = userDid; } else { throw new ArgumentException("This does not look like a userDid"); } }
public UserRecommendationsRequest(string externalID, APISettings settings) : base(settings) { if (!string.IsNullOrEmpty(externalID)) { _ExternalID = externalID; } else { throw new ArgumentNullException("externalID", "ExternalID is requried"); } }
public AuthService(IConfiguration config, SMEAPIContext db, IOptions <ApiURLSettings> apiURLSettings, IOptions <APISettings> apiSettings, IAuthRepository <LoggedUser> loggedUserRepository) { _config = config; _db = db; this.apiURLSettings = apiURLSettings.Value; this.apiSettings = apiSettings.Value; this.loggedUserRepository = loggedUserRepository; }
internal JobRequest(string jobDid, APISettings settings) : base(settings) { if (string.IsNullOrEmpty(jobDid)) { throw new ArgumentNullException(); } if (jobDid.Length >= 18 && jobDid.Length <= 20 && jobDid.StartsWith("J", StringComparison.InvariantCultureIgnoreCase)) { _jobDid = jobDid; } else { throw new ArgumentException("This does not look like a job did"); } }
public void BaseURL_IsNotSecure_WhenTargetSiteIsntSecure() { //Setup var newSite = new TargetSiteMock("127.0.0.1") { SetHost = "www.google.com", SetSecure = false }; var settings = new APISettings() { DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite }; var request = new GetRequestStub(settings); Assert.AreEqual("http://127.0.0.1/Exammple", request.GetRequestURL); }
public void SaveAndLoad() { string path = "TestAPISettings.rpxml"; if (File.Exists(path)) { File.Delete(path); } APISettings.Load(path); Assert.AreEqual(APISettings.APIVersion, APISettings.DEFAULT_API_VER, "API version mismatch"); APISettings.Save(path); Assert.IsTrue(File.Exists(path), "Failed to save settings"); File.Delete(path); return; }
public JobRecommendationsRequest(string jobDid, APISettings settings) : base(settings) { if (string.IsNullOrEmpty(jobDid)) { throw new ArgumentNullException(); } if (jobDid.Length >= 18 && jobDid.Length <= 20 && jobDid.StartsWith("J", StringComparison.InvariantCultureIgnoreCase)) { _jobDid = jobDid; } else { throw new ArgumentException("This does not look like a jobDid"); } }
public void SetUp() { var apiSettingsWithoutParameters = new APISettings { Endpoint = this.AppSettings.APIConfig.EndpointBaseUrl.ProfileSummary }; var tempAppSettings = new AppSettings { APIConfig = new APIConfig { ApimSubscriptionKey = this.CommonAction.RandomString(10), Version = this.AppSettings.APIConfig.Version, }, }; this.authorisedApi = new JobProfileApi(new RestClientFactory(), new RestRequestFactory(), this.AppSettings, apiSettingsWithoutParameters); this.unauthorisedApi = new JobProfileApi(new RestClientFactory(), new RestRequestFactory(), tempAppSettings, apiSettingsWithoutParameters); }
protected GetRequest(APISettings settings) { if (settings == null) { throw new ArgumentNullException("settings", "You must provide valid API Settings"); } _Settings = settings; if (string.IsNullOrEmpty(settings.DevKey)) { throw new ArgumentNullException("DevKey", "Please provide a valid developer key"); } if (settings.TargetSite == null) { throw new ArgumentNullException("TargetSite", "Please provide a valid domain name"); } if (settings.TargetSite != null && string.IsNullOrEmpty(settings.TargetSite.Domain)) { throw new ArgumentNullException("TargetSite", "Please provide a valid domain name"); } }
public BlankApplicationRequest(string jobDid, APISettings settings) : base(settings) { if (string.IsNullOrEmpty(jobDid)) { throw new ArgumentNullException(); } if (jobDid.Length >= 18 && jobDid.Length <= 20 && jobDid.StartsWith("J", StringComparison.InvariantCultureIgnoreCase)) { JobDid = jobDid; } else { throw new ArgumentException("This does not look like a job did"); } ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; }
public AnonymousApplication(APISettings settings) : base(settings) { DeveloperKey = settings.DevKey; }
public CustomersController(IOptions <APISettings> apiSettings) { _apiSettings = apiSettings.Value; }
public EmployeeTypesRequest(APISettings settings) : base(settings) { }
public JobReportRequest(string jobDid, APISettings settings) : base(settings) { _jobDid = jobDid; }
public UserRecommendationsRequest(QsParam QsParam, APISettings settings) : base(settings) { this._QsParams.Add(QsParam); }
public EducationCodesRequest(APISettings settings) : base(settings) { }
public SavedSearchUpdateRequest(APISettings settings) : base(settings) { DeveloperKey = settings.DevKey; }
public CategoriesRequest(APISettings settings) : base(settings) { }
public JobSearchRequest(APISettings settings) : base(settings) { }
public UserRecommendationsRequest(List <QsParam> QsParams, APISettings settings) : base(settings) { this._QsParams = QsParams; }
public UserRecommendationsRequest(List<QsParam> QsParams, APISettings settings) : base(settings) { this._QsParams = QsParams; }
public HomeController(IOptions <APISettings> apiSettings) { _apiSettings = apiSettings.Value; }
public SubmitApplicationRequest(APISettings settings) : base(settings) { }