public void MsalServiceException_Oauth2Response_Only() { // Arrange HttpResponse httpResponse = new HttpResponse() { Body = jsonError, StatusCode = HttpStatusCode.BadRequest, // 400 }; OAuth2ResponseBase oAuth2Response = JsonHelper.TryToDeserializeFromJson <OAuth2ResponseBase>(httpResponse?.Body); // Act var msalException = new MsalServiceException(ExCode, ExMessage) { OAuth2Response = oAuth2Response }; // Assert var msalServiceException = msalException as MsalServiceException; Assert.AreEqual(ExCode, msalServiceException.ErrorCode); Assert.AreEqual(ExMessage, msalServiceException.Message); Assert.AreEqual("some_claims", msalServiceException.Claims); Assert.AreEqual("6347d33d-941a-4c35-9912-a9cf54fb1b3e", msalServiceException.CorrelationId); Assert.AreEqual("some_suberror", msalServiceException.SubError); }
private OAuth2ResponseBase InitOAuth2ResponseBase(OAuth2ResponseBase oAuth2ResponseBase) { oAuth2ResponseBase.Error = "OAuth error"; oAuth2ResponseBase.SubError = "OAuth suberror"; oAuth2ResponseBase.ErrorDescription = "OAuth error description"; oAuth2ResponseBase.ErrorCodes = new[] { "error1", "error2", "error3" }; oAuth2ResponseBase.CorrelationId = "1234-123-1234"; oAuth2ResponseBase.Claims = "claim1 claim2"; return(oAuth2ResponseBase); }
public JsonTests() { _oAuth2ResponseBase = InitOAuth2ResponseBase(new OAuth2ResponseBase()); _oAuth2ResponseBaseJson = JsonHelper.SerializeToJson <OAuth2ResponseBase>(_oAuth2ResponseBase); _msalTokenResponse = InitMsalTokenResponse(new MsalTokenResponse()); _msalTokenResponseJson = JsonHelper.SerializeToJson <MsalTokenResponse>(_msalTokenResponse); _instanceDiscoveryResponse = InitInstanceDiscoveryResponse(new InstanceDiscoveryResponse()); _instanceDiscoveryResponseJson = JsonHelper.SerializeToJson <InstanceDiscoveryResponse>(_instanceDiscoveryResponse); }
private static bool IsThrottled(OAuth2ResponseBase oAuth2Response) { return(oAuth2Response.ErrorDescription != null && oAuth2Response.ErrorDescription.StartsWith(Constants.AadThrottledErrorCode)); }
private static bool IsInvalidGrant(OAuth2ResponseBase oAuth2Response) { return(string.Equals(oAuth2Response?.Error, MsalError.InvalidGrantError, StringComparison.OrdinalIgnoreCase) && IsInvalidGrantSubError(oAuth2Response?.SubError)); }
private static bool IsInteractionRequired(OAuth2ResponseBase oAuth2Response) { return(string.Equals(oAuth2Response?.Error, MsalError.InteractionRequired, StringComparison.OrdinalIgnoreCase)); }