mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
Merge branch 'foss42:main' into add-feature-scripts
This commit is contained in:
@@ -11,7 +11,10 @@ A List of API endpoints that can be used for testing API Dash
|
||||
|
||||
#### For Testing HTTP PUT, PATCH, DELETE
|
||||
- https://reqres.in/
|
||||
|
||||
|
||||
#### For Testing HTTP OPTIONS
|
||||
- https://reqbin.com/echo/options
|
||||
|
||||
#### For Testing sites with Bad Certificate
|
||||
- https://badssl.com/
|
||||
- https://www.ssl.com/sample-valid-revoked-and-expired-ssl-tls-certificates/
|
||||
|
||||
@@ -44,4 +44,5 @@ const _$HTTPVerbEnumMap = {
|
||||
HTTPVerb.put: 'put',
|
||||
HTTPVerb.patch: 'patch',
|
||||
HTTPVerb.delete: 'delete',
|
||||
HTTPVerb.options: 'options',
|
||||
};
|
||||
|
||||
@@ -51,6 +51,7 @@ Color getHTTPMethodColor(HTTPVerb? method) {
|
||||
HTTPVerb.put => kColorHttpMethodPut,
|
||||
HTTPVerb.patch => kColorHttpMethodPatch,
|
||||
HTTPVerb.delete => kColorHttpMethodDelete,
|
||||
HTTPVerb.options => kColorHttpMethodOptions,
|
||||
_ => kColorHttpMethodGet,
|
||||
};
|
||||
return col;
|
||||
|
||||
@@ -17,7 +17,8 @@ enum HTTPVerb {
|
||||
post("POST"),
|
||||
put("PUT"),
|
||||
patch("PAT"),
|
||||
delete("DEL");
|
||||
delete("DEL"),
|
||||
options("OPT");
|
||||
|
||||
const HTTPVerb(this.abbr);
|
||||
final String abbr;
|
||||
|
||||
@@ -58,6 +58,7 @@ const _$HTTPVerbEnumMap = {
|
||||
HTTPVerb.put: 'put',
|
||||
HTTPVerb.patch: 'patch',
|
||||
HTTPVerb.delete: 'delete',
|
||||
HTTPVerb.options: 'options',
|
||||
};
|
||||
|
||||
const _$ContentTypeEnumMap = {
|
||||
|
||||
@@ -94,6 +94,7 @@ Future<(HttpResponse?, Duration?, String?)> sendHttpRequest(
|
||||
case HTTPVerb.put:
|
||||
case HTTPVerb.patch:
|
||||
case HTTPVerb.delete:
|
||||
case HTTPVerb.options:
|
||||
final request = prepareHttpRequest(
|
||||
url: requestUrl,
|
||||
method: requestModel.method.name.toUpperCase(),
|
||||
|
||||
@@ -23,6 +23,7 @@ final kColorHttpMethodPost = Colors.blue.shade800;
|
||||
final kColorHttpMethodPut = Colors.amber.shade900;
|
||||
final kColorHttpMethodPatch = kColorHttpMethodPut;
|
||||
final kColorHttpMethodDelete = Colors.red.shade800;
|
||||
final kColorHttpMethodOptions = Colors.deepPurple.shade800;
|
||||
|
||||
final kColorGQL = Colors.pink.shade600;
|
||||
|
||||
|
||||
@@ -466,3 +466,9 @@ const httpRequestModelPost13 = HttpRequestModel(
|
||||
"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,
|
||||
httpRequestModel: httpRequestModelPost13,
|
||||
);
|
||||
|
||||
const requestModelOptions1 = RequestModel(
|
||||
id: 'options1',
|
||||
apiType: APIType.rest,
|
||||
httpRequestModel: httpRequestModelOptions1,
|
||||
);
|
||||
|
||||
@@ -119,4 +119,21 @@ void main() {
|
||||
test('Testing hashcode', () {
|
||||
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