TF-4136 Remove all content-length in header request of mock unit test avoid run test fail
This commit is contained in:
@@ -81,7 +81,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 330
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final httpClient = HttpClient(dio);
|
final httpClient = HttpClient(dio);
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 162
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 868
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -163,7 +162,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 256
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 162
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 424
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 292
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final httpClient = HttpClient(dio);
|
final httpClient = HttpClient(dio);
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 765
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 250
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final httpClient = HttpClient(dio);
|
final httpClient = HttpClient(dio);
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 753
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final setRuleFilterMethod = SetRuleFilterMethod(AccountId(Id(
|
final setRuleFilterMethod = SetRuleFilterMethod(AccountId(Id(
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 233
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 503
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -41,14 +41,14 @@ void main() {
|
|||||||
const responseStatusCode500 = 500;
|
const responseStatusCode500 = 500;
|
||||||
const responseStatusCode200 = 200;
|
const responseStatusCode200 = 200;
|
||||||
|
|
||||||
final dioError401 = DioError(
|
final dioError401 = DioException(
|
||||||
error: {'message': 'Token Expired'},
|
error: {'message': 'Token Expired'},
|
||||||
requestOptions: RequestOptions(path: baseUrl, method: 'POST'),
|
requestOptions: RequestOptions(path: baseUrl, method: 'POST'),
|
||||||
response: Response(
|
response: Response(
|
||||||
statusCode: responseStatusCode401,
|
statusCode: responseStatusCode401,
|
||||||
requestOptions: RequestOptions(path: baseUrl)
|
requestOptions: RequestOptions(path: baseUrl)
|
||||||
),
|
),
|
||||||
type: DioErrorType.badResponse,
|
type: DioExceptionType.badResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
final dataRequestSuccessfully = {'message': 'Request successfully!'};
|
final dataRequestSuccessfully = {'message': 'Request successfully!'};
|
||||||
@@ -240,24 +240,24 @@ void main() {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
() async => await dio.post(baseUrl),
|
() async => await dio.post(baseUrl),
|
||||||
throwsA(predicate<DioError>((error) => error.response?.statusCode == responseStatusCode401))
|
throwsA(predicate<DioException>((error) => error.response?.statusCode == responseStatusCode401))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('AuthorizationInterceptor: multiple requests queued on onError', () {
|
group('AuthorizationInterceptor: multiple requests queued on onError', () {
|
||||||
final requestOneDioError401 = DioError(
|
final requestOneDioError401 = DioException(
|
||||||
error: {'message': 'Token Expired'},
|
error: {'message': 'Token Expired'},
|
||||||
requestOptions: RequestOptions(path: '$baseUrl/1', method: 'POST'),
|
requestOptions: RequestOptions(path: '$baseUrl/1', method: 'POST'),
|
||||||
response: Response(
|
response: Response(
|
||||||
statusCode: responseStatusCode401,
|
statusCode: responseStatusCode401,
|
||||||
requestOptions: RequestOptions(path: '$baseUrl/1')
|
requestOptions: RequestOptions(path: '$baseUrl/1')
|
||||||
),
|
),
|
||||||
type: DioErrorType.badResponse,
|
type: DioExceptionType.badResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
final requestTwoDioError401 = DioError(
|
final requestTwoDioError401 = DioException(
|
||||||
error: {'message': 'Token Expired'},
|
error: {'message': 'Token Expired'},
|
||||||
requestOptions: RequestOptions(
|
requestOptions: RequestOptions(
|
||||||
path: '$baseUrl/2',
|
path: '$baseUrl/2',
|
||||||
@@ -268,7 +268,7 @@ void main() {
|
|||||||
statusCode: responseStatusCode401,
|
statusCode: responseStatusCode401,
|
||||||
requestOptions: RequestOptions(path: '$baseUrl/2')
|
requestOptions: RequestOptions(path: '$baseUrl/2')
|
||||||
),
|
),
|
||||||
type: DioErrorType.badResponse,
|
type: DioExceptionType.badResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
test('GIVEN 2 requests have token expired\n'
|
test('GIVEN 2 requests have token expired\n'
|
||||||
@@ -367,7 +367,7 @@ void main() {
|
|||||||
dio.post('$baseUrl/1',),
|
dio.post('$baseUrl/1',),
|
||||||
dio.post('$baseUrl/2',)
|
dio.post('$baseUrl/2',)
|
||||||
]),
|
]),
|
||||||
throwsA(predicate<DioError>(
|
throwsA(predicate<DioException>(
|
||||||
(dioError) => dioError.error is AccessTokenInvalidException))
|
(dioError) => dioError.error is AccessTokenInvalidException))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ void main() {
|
|||||||
test(
|
test(
|
||||||
'should throw CanNotFoundOIDCLinks '
|
'should throw CanNotFoundOIDCLinks '
|
||||||
'when checkOIDCIsAvailable() is called '
|
'when checkOIDCIsAvailable() is called '
|
||||||
'and dioClient throw DioError '
|
'and dioClient throw DioException '
|
||||||
'and status code is 404',
|
'and status code is 404',
|
||||||
() {
|
() {
|
||||||
// arrange
|
// arrange
|
||||||
when(dioClient.get(any)).thenThrow(DioError(
|
when(dioClient.get(any)).thenThrow(DioException(
|
||||||
requestOptions: requestOptions,
|
requestOptions: requestOptions,
|
||||||
response: Response(requestOptions: requestOptions, statusCode: 404)));
|
response: Response(requestOptions: requestOptions, statusCode: 404)));
|
||||||
|
|
||||||
@@ -37,11 +37,11 @@ void main() {
|
|||||||
test(
|
test(
|
||||||
'should throw CanRetryOIDCException '
|
'should throw CanRetryOIDCException '
|
||||||
'when checkOIDCIsAvailable() is called '
|
'when checkOIDCIsAvailable() is called '
|
||||||
'and dioClient throw DioError '
|
'and dioClient throw DioException '
|
||||||
'and status code is not 404',
|
'and status code is not 404',
|
||||||
() {
|
() {
|
||||||
// arrange
|
// arrange
|
||||||
when(dioClient.get(any)).thenThrow(DioError(
|
when(dioClient.get(any)).thenThrow(DioException(
|
||||||
requestOptions: requestOptions,
|
requestOptions: requestOptions,
|
||||||
response: Response(requestOptions: requestOptions, statusCode: 403)));
|
response: Response(requestOptions: requestOptions, statusCode: 403)));
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ void main() {
|
|||||||
test(
|
test(
|
||||||
'should throw CanRetryOIDCException '
|
'should throw CanRetryOIDCException '
|
||||||
'when checkOIDCIsAvailable() is called '
|
'when checkOIDCIsAvailable() is called '
|
||||||
'and dioClient throw exception that is not DioError',
|
'and dioClient throw exception that is not DioException',
|
||||||
() {
|
() {
|
||||||
// arrange
|
// arrange
|
||||||
when(dioClient.get(any)).thenThrow(Exception());
|
when(dioClient.get(any)).thenThrow(Exception());
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ void main() {
|
|||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"accept": "application/json;jmapVersion=rfc-8621",
|
"accept": "application/json;jmapVersion=rfc-8621",
|
||||||
"content-length": 503
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ void main() {
|
|||||||
propertiesCreated: defaultCreatedProperties,
|
propertiesCreated: defaultCreatedProperties,
|
||||||
propertiesUpdated: defaultUpdatedProperties,
|
propertiesUpdated: defaultUpdatedProperties,
|
||||||
),
|
),
|
||||||
headers: dioAdapterHeaders..addAll({'content-length': 1245}),
|
headers: dioAdapterHeaders,
|
||||||
);
|
);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -662,7 +662,7 @@ void main() {
|
|||||||
propertiesCreated: defaultCreatedProperties,
|
propertiesCreated: defaultCreatedProperties,
|
||||||
propertiesUpdated: defaultUpdatedProperties,
|
propertiesUpdated: defaultUpdatedProperties,
|
||||||
),
|
),
|
||||||
headers: dioAdapterHeaders..addAll({'content-length': 1245}),
|
headers: dioAdapterHeaders
|
||||||
);
|
);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -714,7 +714,7 @@ void main() {
|
|||||||
data: generateRequest(
|
data: generateRequest(
|
||||||
propertiesCreated: defaultCreatedProperties,
|
propertiesCreated: defaultCreatedProperties,
|
||||||
),
|
),
|
||||||
headers: dioAdapterHeaders..addAll({'content-length': 798}),
|
headers: dioAdapterHeaders
|
||||||
);
|
);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -752,7 +752,7 @@ void main() {
|
|||||||
generateResponse(),
|
generateResponse(),
|
||||||
),
|
),
|
||||||
data: generateRequest(),
|
data: generateRequest(),
|
||||||
headers: dioAdapterHeaders..addAll({'content-length': 355}),
|
headers: dioAdapterHeaders
|
||||||
);
|
);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
|
|||||||
Reference in New Issue
Block a user