mirror of
https://github.com/foss42/apidash.git
synced 2025-08-24 04:51:22 +08:00
Merge branch 'main' into patch-5
This commit is contained in:
@ -427,3 +427,17 @@ const httpRequestModelGetBadSSL = HttpRequestModel(
|
||||
method: HTTPVerb.get,
|
||||
url: 'https://expired.badssl.com/',
|
||||
);
|
||||
|
||||
/// POST request model with content type override having no charset
|
||||
const httpRequestModelPost11 = HttpRequestModel(
|
||||
method: HTTPVerb.post,
|
||||
url: 'https://api.apidash.dev/case/lower',
|
||||
headers: [
|
||||
NameValueModel(name: 'Content-Type', value: 'application/json'),
|
||||
],
|
||||
isHeaderEnabledList: [true],
|
||||
bodyContentType: ContentType.json,
|
||||
body: r"""{
|
||||
"text": "I LOVE Flutter"
|
||||
}""",
|
||||
);
|
||||
|
@ -1,177 +1,207 @@
|
||||
import 'package:apidash/models/models.dart';
|
||||
import 'package:apidash_core/apidash_core.dart';
|
||||
import 'http_request_models.dart';
|
||||
import 'http_response_models.dart';
|
||||
|
||||
/// Basic GET request model
|
||||
const requestModelGet1 = RequestModel(
|
||||
id: 'get1',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet1,
|
||||
);
|
||||
|
||||
/// GET request model with query params
|
||||
const requestModelGet2 = RequestModel(
|
||||
id: 'get2',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet2,
|
||||
);
|
||||
|
||||
/// GET request model with override query params
|
||||
const requestModelGet3 = RequestModel(
|
||||
id: 'get3',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet3,
|
||||
);
|
||||
|
||||
/// GET request model with different types of query params
|
||||
const requestModelGet4 = RequestModel(
|
||||
id: 'get4',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet4,
|
||||
);
|
||||
|
||||
/// GET request model with headers
|
||||
const requestModelGet5 = RequestModel(
|
||||
id: 'get5',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet5,
|
||||
);
|
||||
|
||||
/// GET request model with headers & query params
|
||||
const requestModelGet6 = RequestModel(
|
||||
id: 'get6',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet6,
|
||||
);
|
||||
|
||||
/// GET request model with body
|
||||
const requestModelGet7 = RequestModel(
|
||||
id: 'get7',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet7,
|
||||
);
|
||||
|
||||
/// GET request model with empty header & query param name
|
||||
const requestModelGet8 = RequestModel(
|
||||
id: 'get8',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet8,
|
||||
);
|
||||
|
||||
/// GET request model with some params enabled
|
||||
const requestModelGet9 = RequestModel(
|
||||
id: 'get9',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet9,
|
||||
);
|
||||
|
||||
/// GET Request model with some headers enabled
|
||||
const requestModelGet10 = RequestModel(
|
||||
id: 'get10',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet10,
|
||||
);
|
||||
|
||||
/// GET Request model with some headers & URL parameters enabled
|
||||
const requestModelGet11 = RequestModel(
|
||||
id: 'get11',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet11,
|
||||
);
|
||||
|
||||
/// Request model with all headers & URL parameters disabled
|
||||
const requestModelGet12 = RequestModel(
|
||||
id: 'get12',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet12,
|
||||
);
|
||||
|
||||
/// Basic HEAD request model
|
||||
const requestModelHead1 = RequestModel(
|
||||
id: 'head1',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelHead1,
|
||||
);
|
||||
|
||||
/// Without URI Scheme (pass default as http)
|
||||
const requestModelHead2 = RequestModel(
|
||||
id: 'head2',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelHead2,
|
||||
);
|
||||
|
||||
/// Basic POST request model (txt body)
|
||||
const requestModelPost1 = RequestModel(
|
||||
id: 'post1',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost1,
|
||||
);
|
||||
|
||||
/// POST request model with JSON body
|
||||
const requestModelPost2 = RequestModel(
|
||||
id: 'post2',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost2,
|
||||
);
|
||||
|
||||
/// POST request model with headers
|
||||
const requestModelPost3 = RequestModel(
|
||||
id: 'post3',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost3,
|
||||
);
|
||||
|
||||
/// POST request model with multipart body(text)
|
||||
const requestModelPost4 = RequestModel(
|
||||
id: 'post4',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost4,
|
||||
);
|
||||
|
||||
/// POST request model with multipart body and headers
|
||||
const requestModelPost5 = RequestModel(
|
||||
id: 'post5',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost5,
|
||||
);
|
||||
|
||||
/// POST request model with multipart body(text, file)
|
||||
const requestModelPost6 = RequestModel(
|
||||
id: 'post6',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost6,
|
||||
);
|
||||
|
||||
/// POST request model with multipart body and requestBody (the requestBody shouldn't be in codegen)
|
||||
const requestModelPost7 = RequestModel(
|
||||
id: 'post7',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost7,
|
||||
);
|
||||
|
||||
/// POST request model with multipart body and requestParams
|
||||
const requestModelPost8 = RequestModel(
|
||||
id: 'post8',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost8,
|
||||
);
|
||||
|
||||
/// POST request model with multipart body(file and text), requestParams, requestHeaders and requestBody
|
||||
const requestModelPost9 = RequestModel(
|
||||
id: 'post9',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost9,
|
||||
);
|
||||
|
||||
const requestModelPost10 = RequestModel(
|
||||
id: 'post9',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost10,
|
||||
);
|
||||
|
||||
/// PUT request model
|
||||
const requestModelPut1 = RequestModel(
|
||||
id: 'put1',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPut1,
|
||||
);
|
||||
|
||||
/// PATCH request model
|
||||
const requestModelPatch1 = RequestModel(
|
||||
id: 'patch1',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPatch1,
|
||||
);
|
||||
|
||||
/// Basic DELETE request model
|
||||
const requestModelDelete1 = RequestModel(
|
||||
id: 'delete1',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelDelete1,
|
||||
);
|
||||
|
||||
/// Basic DELETE with body
|
||||
const requestModelDelete2 = RequestModel(
|
||||
id: 'delete2',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelDelete2,
|
||||
);
|
||||
|
||||
// full request model
|
||||
RequestModel testRequestModel = RequestModel(
|
||||
id: '1',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost10,
|
||||
responseStatus: 200,
|
||||
httpResponseModel: responseModel,
|
||||
@ -192,11 +222,19 @@ Map<String, dynamic> requestModelJson = {
|
||||
/// Basic GET request model for apidash.dev
|
||||
const requestModelGet13 = RequestModel(
|
||||
id: 'get13',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGet13,
|
||||
);
|
||||
|
||||
/// Basic GET request model for badSSL
|
||||
const requestModelGetBadSSL = RequestModel(
|
||||
id: 'badSSL',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelGetBadSSL,
|
||||
);
|
||||
|
||||
const requestModelPost11 = RequestModel(
|
||||
id: 'post11',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelPost11,
|
||||
);
|
||||
|
@ -34,7 +34,7 @@ void main() {
|
||||
test('Testing fromResponse for contentType not Json', () async {
|
||||
var responseRec = await sendHttpRequest(
|
||||
requestModelGet13.id,
|
||||
requestModelGet1.apiType,
|
||||
requestModelGet13.apiType,
|
||||
requestModelGet13.httpRequestModel!,
|
||||
defaultUriScheme: kDefaultUriScheme,
|
||||
noSSL: false,
|
||||
@ -47,10 +47,25 @@ void main() {
|
||||
expect(responseData.mediaType!.mimeType, 'text/html');
|
||||
});
|
||||
|
||||
test('Testing contentType override by the user having no charset (#630)',
|
||||
() async {
|
||||
var responseRec = await sendHttpRequest(
|
||||
requestModelPost11.id,
|
||||
requestModelPost11.apiType,
|
||||
requestModelPost11.httpRequestModel!,
|
||||
);
|
||||
|
||||
final responseData = responseModel.fromResponse(response: responseRec.$1!);
|
||||
expect(responseData.statusCode, 200);
|
||||
expect(responseData.body, '{"data":"i love flutter"}');
|
||||
expect(responseData.contentType, 'application/json; charset=utf-8');
|
||||
expect(responseData.requestHeaders?['content-type'], 'application/json');
|
||||
});
|
||||
|
||||
test('Testing fromResponse for Bad SSL with certificate check', () async {
|
||||
var responseRec = await sendHttpRequest(
|
||||
requestModelGetBadSSL.id,
|
||||
requestModelGet1.apiType,
|
||||
requestModelGetBadSSL.apiType,
|
||||
requestModelGetBadSSL.httpRequestModel!,
|
||||
defaultUriScheme: kDefaultUriScheme,
|
||||
noSSL: false,
|
||||
@ -62,7 +77,7 @@ void main() {
|
||||
test('Testing fromResponse for Bad SSL with no certificate check', () async {
|
||||
var responseRec = await sendHttpRequest(
|
||||
requestModelGetBadSSL.id,
|
||||
requestModelGet1.apiType,
|
||||
requestModelGetBadSSL.apiType,
|
||||
requestModelGetBadSSL.httpRequestModel!,
|
||||
defaultUriScheme: kDefaultUriScheme,
|
||||
noSSL: true,
|
||||
|
Reference in New Issue
Block a user