mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
Merge branch 'foss42:main' into add-feature-scripts
This commit is contained in:
@@ -12,6 +12,9 @@ A List of API endpoints that can be used for testing API Dash
|
|||||||
#### For Testing HTTP PUT, PATCH, DELETE
|
#### For Testing HTTP PUT, PATCH, DELETE
|
||||||
- https://reqres.in/
|
- https://reqres.in/
|
||||||
|
|
||||||
|
#### For Testing HTTP OPTIONS
|
||||||
|
- https://reqbin.com/echo/options
|
||||||
|
|
||||||
#### For Testing sites with Bad Certificate
|
#### For Testing sites with Bad Certificate
|
||||||
- https://badssl.com/
|
- https://badssl.com/
|
||||||
- https://www.ssl.com/sample-valid-revoked-and-expired-ssl-tls-certificates/
|
- https://www.ssl.com/sample-valid-revoked-and-expired-ssl-tls-certificates/
|
||||||
|
|||||||
@@ -44,4 +44,5 @@ const _$HTTPVerbEnumMap = {
|
|||||||
HTTPVerb.put: 'put',
|
HTTPVerb.put: 'put',
|
||||||
HTTPVerb.patch: 'patch',
|
HTTPVerb.patch: 'patch',
|
||||||
HTTPVerb.delete: 'delete',
|
HTTPVerb.delete: 'delete',
|
||||||
|
HTTPVerb.options: 'options',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ Color getHTTPMethodColor(HTTPVerb? method) {
|
|||||||
HTTPVerb.put => kColorHttpMethodPut,
|
HTTPVerb.put => kColorHttpMethodPut,
|
||||||
HTTPVerb.patch => kColorHttpMethodPatch,
|
HTTPVerb.patch => kColorHttpMethodPatch,
|
||||||
HTTPVerb.delete => kColorHttpMethodDelete,
|
HTTPVerb.delete => kColorHttpMethodDelete,
|
||||||
|
HTTPVerb.options => kColorHttpMethodOptions,
|
||||||
_ => kColorHttpMethodGet,
|
_ => kColorHttpMethodGet,
|
||||||
};
|
};
|
||||||
return col;
|
return col;
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ enum HTTPVerb {
|
|||||||
post("POST"),
|
post("POST"),
|
||||||
put("PUT"),
|
put("PUT"),
|
||||||
patch("PAT"),
|
patch("PAT"),
|
||||||
delete("DEL");
|
delete("DEL"),
|
||||||
|
options("OPT");
|
||||||
|
|
||||||
const HTTPVerb(this.abbr);
|
const HTTPVerb(this.abbr);
|
||||||
final String abbr;
|
final String abbr;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ const _$HTTPVerbEnumMap = {
|
|||||||
HTTPVerb.put: 'put',
|
HTTPVerb.put: 'put',
|
||||||
HTTPVerb.patch: 'patch',
|
HTTPVerb.patch: 'patch',
|
||||||
HTTPVerb.delete: 'delete',
|
HTTPVerb.delete: 'delete',
|
||||||
|
HTTPVerb.options: 'options',
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$ContentTypeEnumMap = {
|
const _$ContentTypeEnumMap = {
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ Future<(HttpResponse?, Duration?, String?)> sendHttpRequest(
|
|||||||
case HTTPVerb.put:
|
case HTTPVerb.put:
|
||||||
case HTTPVerb.patch:
|
case HTTPVerb.patch:
|
||||||
case HTTPVerb.delete:
|
case HTTPVerb.delete:
|
||||||
|
case HTTPVerb.options:
|
||||||
final request = prepareHttpRequest(
|
final request = prepareHttpRequest(
|
||||||
url: requestUrl,
|
url: requestUrl,
|
||||||
method: requestModel.method.name.toUpperCase(),
|
method: requestModel.method.name.toUpperCase(),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ final kColorHttpMethodPost = Colors.blue.shade800;
|
|||||||
final kColorHttpMethodPut = Colors.amber.shade900;
|
final kColorHttpMethodPut = Colors.amber.shade900;
|
||||||
final kColorHttpMethodPatch = kColorHttpMethodPut;
|
final kColorHttpMethodPatch = kColorHttpMethodPut;
|
||||||
final kColorHttpMethodDelete = Colors.red.shade800;
|
final kColorHttpMethodDelete = Colors.red.shade800;
|
||||||
|
final kColorHttpMethodOptions = Colors.deepPurple.shade800;
|
||||||
|
|
||||||
final kColorGQL = Colors.pink.shade600;
|
final kColorGQL = Colors.pink.shade600;
|
||||||
|
|
||||||
|
|||||||
@@ -466,3 +466,9 @@ const httpRequestModelPost13 = HttpRequestModel(
|
|||||||
"text": "I LOVE Flutter"
|
"text": "I LOVE Flutter"
|
||||||
}""",
|
}""",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Basic OPTIONS request model
|
||||||
|
const httpRequestModelOptions1 = HttpRequestModel(
|
||||||
|
method: HTTPVerb.options,
|
||||||
|
url: 'https://reqbin.com/echo/options',
|
||||||
|
);
|
||||||
|
|||||||
@@ -253,3 +253,9 @@ const requestModelPost13 = RequestModel(
|
|||||||
apiType: APIType.rest,
|
apiType: APIType.rest,
|
||||||
httpRequestModel: httpRequestModelPost13,
|
httpRequestModel: httpRequestModelPost13,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const requestModelOptions1 = RequestModel(
|
||||||
|
id: 'options1',
|
||||||
|
apiType: APIType.rest,
|
||||||
|
httpRequestModel: httpRequestModelOptions1,
|
||||||
|
);
|
||||||
|
|||||||
@@ -119,4 +119,21 @@ void main() {
|
|||||||
test('Testing hashcode', () {
|
test('Testing hashcode', () {
|
||||||
expect(responseModel.hashCode, greaterThan(0));
|
expect(responseModel.hashCode, greaterThan(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Testing fromResponse for OPTIONS method', () async {
|
||||||
|
var responseRec = await sendHttpRequest(
|
||||||
|
requestModelOptions1.id,
|
||||||
|
requestModelOptions1.apiType,
|
||||||
|
requestModelOptions1.httpRequestModel!,
|
||||||
|
defaultUriScheme: kDefaultUriScheme,
|
||||||
|
noSSL: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
final responseData = responseModel.fromResponse(response: responseRec.$1!);
|
||||||
|
expect(responseData.statusCode, 200);
|
||||||
|
expect(responseData.headers?['access-control-allow-methods'], 'GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS');
|
||||||
|
expect(responseData.headers?['access-control-allow-methods']?.contains("OPTIONS"), true);
|
||||||
|
expect(responseData.headers?['allow'], 'GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS');
|
||||||
|
expect(responseData.headers?['allow']?.contains("OPTIONS"), true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user