コード例 #1
0
        public void InvalidJsonInRefreshTokenRequestTest(JsonTransformationType jsonTransformationType)
        {
            var tokenGetRequest = new GetTokenRequest
            {
                ExpiresIn    = 600,
                ExtPayload   = new { sessionId = "qwer123" },
                InvalidAfter = 10800,
                Method       = "password",
                Service      = "HRBC",
                Credentials  = new GetTokenRequest.CredentialsType
                {
                    CompanyId = AuthenticationInfoProvider.Current.DefaultCompanyName,
                    UserId    = AuthenticationInfoProvider.Current.DefaultUserLogin,
                    Password  = AuthenticationInfoProvider.Current.DefaultUserPassword
                }
            };

            var tokenGetResponse = (new DefaultManager(_testConnection)).Send <GetTokenResponse>(tokenGetRequest);

            PrAssume.That(tokenGetResponse, PrIs.SuccessfulResponse(), "Failed to get a token for token refresh operation.");

            var request = new RefreshTokenRequest
            {
                ExpiresIn    = 600,
                InvalidAfter = 10800,
                Token        = tokenGetResponse.Result.Token
            };

            PerformTest(tokenGetRequest, jsonTransformationType, CommonConstants.TokenRefreshUrl);
        }
コード例 #2
0
 public static string GetErrorFieldForInvalidFormatJson(JsonTransformationType jsonTransformationType, object request)
 {
     //if (jsonTransformationType == JsonTransformationType.ArrayForProp || jsonTransformationType == JsonTransformationType.ObjForProp)
     //{
     //    return JObject.FromObject(request).Properties().First().Name;
     //}
     return($"$.{JObject.FromObject(request).Properties().First().Name}");
 }
コード例 #3
0
        public void InvalidJsonInLoginRequestTest(JsonTransformationType jsonTransformationType)
        {
            var request = new LoginRequest
            {
                CompanyId      = Convert.ToInt32(AuthenticationInfoProvider.Current.DefaultPartition),
                CompanyLoginId = AuthenticationInfoProvider.Current.DefaultCompanyName
            };

            PerformTest(request, jsonTransformationType, CommonConstants.LoginUrl);
        }
コード例 #4
0
        public void InvalidJsonInUpdateSettingsRequestTest(JsonTransformationType jsonTransformationType)
        {
            var request = new SettingSetRequest
            {
                AllowedRolePwdLogin = 2,
                ComnanyId           = Convert.ToInt32(AuthenticationInfoProvider.Current.DefaultPartition),
                LoginUrl            = "http://test.adfs.com/",
                SsoEnabled          = true
            };

            PerformTest(request, jsonTransformationType, CommonConstants.SettingCoreApiUrl);
        }
コード例 #5
0
        private void PerformTest(object request, JsonTransformationType jsonTransformationType, string endpoint, AuthApiConnection connection = null)
        {
            var requestString = ValidationTestData.JsonTransformations[jsonTransformationType](request);

            using (var response = (connection ?? _testConnection).SendAsync(endpoint, requestString, System.Net.Http.HttpMethod.Post).Result)
            {
                PrAssert.That(response.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.BadRequest), "Unexpected response type");
                PrAssert.That(response.Content?.Headers?.ContentType?.MediaType, Is.EqualTo("application/json"), "Unexpected response type");

                var errors = JsonConvert.DeserializeObject <ErrorResponse>(response.Content.ReadAsStringAsync().Result);
                PrAssert.That(errors?.Errors, PrIs.Not.Null.And.Count.EqualTo(1), "Wrong number of errors");
                var error = errors.Errors.Single();
                PrAssert.That(error.Code, Is.EqualTo("NULL_PARAMETER_VALUE"), "Wrong error code");
                PrAssert.That(error.Field, Is.EqualTo(ValidationTestData.GetErrorFieldForInvalidFormatJson(jsonTransformationType, request)), "Wrong error field");
            }
        }
コード例 #6
0
        public void InvalidJsonInGetTokenRequestTest(JsonTransformationType jsonTransformationType)
        {
            var request = new GetTokenRequest
            {
                ExpiresIn    = 600,
                ExtPayload   = new { sessionId = "qwer123" },
                InvalidAfter = 10800,
                Method       = "password",
                Service      = "HRBC",
                Credentials  = new GetTokenRequest.CredentialsType
                {
                    CompanyId = AuthenticationInfoProvider.Current.DefaultCompanyName,
                    UserId    = AuthenticationInfoProvider.Current.DefaultUserLogin,
                    Password  = AuthenticationInfoProvider.Current.DefaultUserPassword
                }
            };

            PerformTest(request, jsonTransformationType, CommonConstants.TokenApiUrl);
        }