/// <summary> /// Common steps to test Claim creation /// </summary> private static void PerformClaimCreationTest(string claimResponse) { Fixture fixture = new Fixture(); ClaimResponse sut = fixture.Create <ClaimResponse>(); TestHelper.PropertiesAreEqual(sut, claimResponse); }
public async Task <ActionResult <OneResponse <List <ClaimResponse> > > > GetClaims(string roleName) { var role = await _roleManager.FindByNameAsync(roleName); if (role == null) { return(NotFound(new OneResponse <object>() { Status = AppConstans.Response_Status_Failed, Message = AppConstans.Response_Message_Get_NotFound })); } var claims = await _roleManager.GetClaimsAsync(role); var claimResponse = new List <ClaimResponse>(); foreach (var item in claims) { var claim = new ClaimResponse { ClaimType = item.Type, ClaimValue = item.Value }; claimResponse.Add(claim); } return(Ok(new OneResponse <List <ClaimResponse> >() { Status = AppConstans.Response_Status_Success, Message = AppConstans.Response_Message_Get_Success, Data = claimResponse })); }
public void ClaimCreationWithHasParamTest() { Hashtable input = JsonConvert.DeserializeObject <Hashtable>(ClaimInput); ClaimResponse actualResponse = claim.Create(input); ClaimSuccessCheck(actualResponse.JsonResponse()); }
public void ClaimCreateAuthenticationExpceptionTest() { Eligible config = Eligible.Instance; config.ApiKey = "Invalid key"; config.IsTest = true; ClaimResponse actualResponse = claim.Create(ClaimInput); }
public ActionResult GetResponse() { ClaimResponse model = new ClaimResponse(); model.Token = GetToken(); model.ClientUserName = GetUserName(); model.ClientPassword = GetPassword(); return(View(model)); }
private static void ClaimSuccessCheck(string actualResponse) { string expectedResponse = TestHelper.GetJson(TestResource.ExpectedResponse + "ClaimSuccess.json"); TestHelper.CompareProperties(expectedResponse, actualResponse); ClaimResponse expectedObj = JsonConvert.DeserializeObject <ClaimResponse>(expectedResponse); ClaimResponse actualObj = JsonConvert.DeserializeObject <ClaimResponse>(actualResponse); TestHelper.PropertyValuesAreEquals(actualObj, expectedObj); }
public void ClaimCreationWithClaimParamsObjectTest() { ClaimParams input = JsonConvert.DeserializeObject <ClaimParams>(ClaimInput); RequestOptions options = new RequestOptions(); options.IsTest = true; ClaimResponse actualResponse = claim.Create(input, options); ClaimSuccessCheck(actualResponse.JsonResponse()); }
public void InvalidBaseUrlOptionTest() { Eligible config = Eligible.Instance; RequestOptions options = new RequestOptions(); options.IsTest = true; options.ApiKey = config.ApiKey; options.BaseUrl = "https://www.example.com/"; Hashtable input = JsonConvert.DeserializeObject <Hashtable>(ClaimInput); ClaimResponse actualResponse = claim.Create(input, options); }
public void ClaimCreationWithRequestOptionsTest() { RequestOptions options = new RequestOptions(); options.IsTest = true; options.ApiKey = null; Hashtable input = JsonConvert.DeserializeObject <Hashtable>(ClaimInput); ClaimResponse actualResponse = claim.Create(input, options); ClaimSuccessCheck(actualResponse.JsonResponse()); }
public async Task <ActionResult> Add([FromBody] ClaimResponse claim) { if (claim == null) { throw new ArgumentNullException(nameof(claim)); } var result = await _claimActions.Add(claim.ToParameter()); await _representationManager.AddOrUpdateRepresentationAsync(this, GetClaimStoreName, false); return(new OkObjectResult(result)); }
public static AddClaimParameter ToParameter(this ClaimResponse request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } return(new AddClaimParameter { Code = request.Code, IsIdentifier = request.IsIdentifier }); }
public async Task <ActionResult <ClaimResponse> > ReassingEpisode([FromBody] TopicReasingPostRequest topicReasing) { User user = null; try { user = await _auth.GetUserFromValidToken(Request); } catch (TokenDoesNotExistException e) { return(Unauthorized()); } catch (Exception e) { _logger.LogError($"Error while trying to get user trying to reassing episode with id: {topicReasing.EpisodeId} to user with id: {topicReasing.UserId}. Error:\n{e.Message}"); SentrySdk.CaptureException(e); return(Problem()); } try { if (!await _auth.CheckIfUserHasElivatedPermission(Request)) { return(Unauthorized()); } _logger.LogInformation($"A user with the id: {user.Id} and the role id: {user.RolesId} is reassigning the episode with the id: {topicReasing.EpisodeId} to the user with the id: {topicReasing.UserId}"); EpisodeExtended episode = await _database.GetMinimalEpisodeAsync(topicReasing.EpisodeId); if (episode.Claimed) { return(BadRequest("Episode is already claimed!")); } ClaimResponse response = await _claim.ReassingClaimAsync(episode, topicReasing.UserId); return(Ok(response)); } catch (TokenDoesNotExistException e) { return(Unauthorized()); } catch (Exception e) { _logger.LogError($"Error while trying to reassing claim. Reassing was requested by user with id: {user.Id}. Episode requested to be reassigned is episode with id: {topicReasing.EpisodeId}. The user it should be reassigned to has is: {topicReasing.UserId}. Error:\n{e.Message}"); SentrySdk.CaptureException(e); } return(Problem()); }
public void ValidBaseUrlOptionTest() { Eligible config = Eligible.Instance; RequestOptions options = new RequestOptions(); options.IsTest = true; options.ApiKey = config.ApiKey; options.BaseUrl = "https://gds.eligibleapi.com/"; Hashtable input = JsonConvert.DeserializeObject <Hashtable>(ClaimInput); ClaimResponse actualResponse = claim.Create(input, options); Assert.IsNotNull(actualResponse.JsonResponse()); }
/// <summary> /// Claim submission with Json formatted string of params /// https://gds.eligibleapi.com/rest#claim_and_reports_create_a_claim /// </summary> /// <param name="claimParams">Please refer Eligible REST doc for claim parameter details</param> /// <returns></returns> public ClaimResponse Create(string jsonParams, RequestOptions options = null) { response = ExecuteObj.ExecutePostPut(EligibleResources.PathToClaims, jsonParams, SetRequestOptionsObject(options)); ClaimResponse formattedResponse = RequestProcess.ResponseValidation <ClaimResponse, ClaimErrors>(response); if (formattedResponse.Success == false) { throw new EligibleException(formattedResponse); } else { formattedResponse.SetJsonResponse(response.Content); return(formattedResponse); } }
public async Task <ActionResult <ClaimResponse> > Post(int id) // id = EpisodeId { if (id == 0) { return(BadRequest("Id cannot be 0!")); } if (id < 0) { return(BadRequest("Id cannot be smaller than 0!")); } try { User user = await _auth.GetUserFromValidToken(Request); EpisodeExtended episode = await _database.GetMinimalEpisodeAsync(id); if (episode.Claimed) { return(BadRequest("Episode is already claimed!")); } ClaimResponse response = await _claim.ClaimEpisodeAsync(episode, user.Id); return(Ok(response)); } catch (EpisodeUnclaimedButAlreadyHasTopcisException e) { return(BadRequest("Episode is already claimed!")); } catch (TokenDoesNotExistException e) { return(Unauthorized()); } catch (Exception e) { if (e.Message.Contains("23505") || e.Message.Contains("unique_user")) { _logger.LogError($"User tried to claim episode wiht id {id}. But the user already claimed another episode."); return(BadRequest("User already has another claimed episode!")); } _logger.LogError($"Error while trying to claim episode with id: {id}. Error:\n{e.Message}"); SentrySdk.CaptureException(e); } return(Problem()); }
public void ClaimCreateAuthenticationExpceptionTest() { Eligible config = Eligible.Instance; config.ApiKey = "Invalid key"; config.IsTest = true; try { ClaimResponse actualResponse = claim.Create(ClaimInput); } catch (Exception ex) { Assert.AreEqual("Could not authenticate you. Please re-try with a valid API key.", ex.Message); } }
public async Task <BaseResponse> ExecuteAsync(Uri claimsUri, ClaimResponse claim, string authorizationHeaderValue = null) { if (claimsUri == null) { throw new ArgumentNullException(nameof(claimsUri)); } if (claim == null) { throw new ArgumentNullException(nameof(claim)); } var httpClient = _httpClientFactory.GetHttpClient(); var serializedJson = JObject.FromObject(claim).ToString(); var body = new StringContent(serializedJson, Encoding.UTF8, "application/json"); var request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = claimsUri, Content = body }; if (!string.IsNullOrWhiteSpace(authorizationHeaderValue)) { request.Headers.Add("Authorization", "Bearer " + authorizationHeaderValue); } var httpResult = await httpClient.SendAsync(request); var content = await httpResult.Content.ReadAsStringAsync().ConfigureAwait(false); try { httpResult.EnsureSuccessStatusCode(); } catch (Exception) { return(new BaseResponse { ContainsError = true, Error = JsonConvert.DeserializeObject <ErrorResponse>(content) }); } return(new BaseResponse()); }
//Add and Update claim Appeal public ClaimResponse AddandUpdateClaimResponse(ClaimResponse claimResponse) { ClaimResponse response = new ClaimResponse(); if (claimResponse.Id == 0) { response = _claimResponse.AddData(claimResponse); } else { response = _claimResponse.UpdateData(claimResponse); } return(response); }
public void InvalidAPIKeyOptionTest() { RequestOptions options = new RequestOptions(); options.IsTest = true; options.ApiKey = "In-Valid"; options.BaseUrl = "https://gds.eligibleapi.com/"; Hashtable input = JsonConvert.DeserializeObject <Hashtable>(ClaimInput); try { ClaimResponse actualResponse = claim.Create(input, options); } catch (Exception ex) { Assert.AreEqual("Could not authenticate you. Please re-try with a valid API key.", ex.Message); } }
public void ClaimExceptionTest() { ClaimParams input = JsonConvert.DeserializeObject <ClaimParams>(ClaimInput); input.Claim.ServiceLines[0].RenderingProvider.Npi = "Invalid NPI"; RequestOptions options = new RequestOptions(); options.IsTest = true; try { ClaimResponse actualResponse = claim.Create(input, options); } catch (EligibleService.Exceptions.EligibleException ex) { string response = TestHelper.GetJson(TestResource.MocksPath + "ClaimFailure.json"); TestHelper.PropertiesAreEqual(ex.EligibleError, ex.Message); } }
public ActionResult GetResponse(ClaimResponse model) { string apiBaseURL = ConfigurationManager.AppSettings["RestAPIURL"]; var request = new RestRequest("/API/GetClaimStatusResponse/" + model.RequestId, Method.GET); //add headers request.AddHeader("Authorization", "Bearer " + model.Token); request.AddHeader("Client-User-Name", model.ClientUserName); // RestClient client = new RestClient(apiBaseURL); //execute the request using rest client object IRestResponse response = client.Execute(request); model.StatusCode = response.StatusCode; model.ApiResponse = response.Content; return(View(model)); }
public ClaimResponse AddandUpdateClaimResponse(ClaimResponse claimResponse) { return(_ClaimResponseService.AddandUpdateClaimResponse(claimResponse)); }
public async Task <BaseResponse> Add(Uri wellKnownConfigurationUri, ClaimResponse claim, string authorizationHeaderValue = null) { var configuration = await _configurationClient.GetConfiguration(wellKnownConfigurationUri).ConfigureAwait(false); return(await _addClaimOperation.ExecuteAsync(new Uri(configuration.Content.ClaimsEndpoint), claim, authorizationHeaderValue).ConfigureAwait(false)); }
public void ClaimCreationWithJsonStringTest() { ClaimResponse actualResponse = claim.Create(ClaimInput); ClaimSuccessCheck(actualResponse.JsonResponse()); }
protected override void ProcessFinishComplete(ClaimResponse response) { AXABulkEventEntryModel model = (AXABulkEventEntryModel)this.Model; model.HasCascadingCalls = true; model.SelectedBulkEventRow.IsProcessed = true; model.OnClaimSave(null); base.ProcessFinishComplete(response); }
protected override void StartTransactionComplete(ClaimResponse claimResponse) { base.StartTransactionComplete(claimResponse); this.GetSearchParameters(); ClaimHeaderData headerData = (ClaimHeaderData)this.Model.HeaderDto.Data; this.SetClaimDetailFilterOnClaimDisplayTransaction(); if (this.Model.HeaderDto.CheckIsEditable()) { this.ValidateDuplicateCommand(); if (this.Model.WizardMode == WizardModeEnum.Copy) { this.SetClientProtected(); } } var claimNameInvolvements = claimResponse.ClaimHeaderDto.ClaimInvolvements.Where(ci => ci.ClaimNameInvolvements != null).SelectMany(ci => ci.ClaimNameInvolvements).ToList(); if (claimNameInvolvements != null) { foreach (ClaimNameInvolvementDto cni in claimNameInvolvements) { IClaimNameInvolvementData cnid = cni.Data as IClaimNameInvolvementData; if (cnid.NameID.HasValue) { NameSearchCache.NameDataCache.Remove(cnid.NameID.Value); Cache.Current.Remove(cnid.NameID.Value); } } } }
public void ClaimCreationWithHasParamEligibleExceptionTest() { Hashtable input = new Hashtable(); ClaimResponse actualResponse = claim.Create(input); }