Merge branch 'foss42:main' into add-feature-scripts

This commit is contained in:
Udhay Adithya
2025-05-01 16:47:38 +05:30
committed by GitHub
10 changed files with 40 additions and 2 deletions

View File

@@ -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/

View File

@@ -44,4 +44,5 @@ const _$HTTPVerbEnumMap = {
HTTPVerb.put: 'put',
HTTPVerb.patch: 'patch',
HTTPVerb.delete: 'delete',
HTTPVerb.options: 'options',
};

View File

@@ -51,6 +51,7 @@ Color getHTTPMethodColor(HTTPVerb? method) {
HTTPVerb.put => kColorHttpMethodPut,
HTTPVerb.patch => kColorHttpMethodPatch,
HTTPVerb.delete => kColorHttpMethodDelete,
HTTPVerb.options => kColorHttpMethodOptions,
_ => kColorHttpMethodGet,
};
return col;

View File

@@ -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;

View File

@@ -58,6 +58,7 @@ const _$HTTPVerbEnumMap = {
HTTPVerb.put: 'put',
HTTPVerb.patch: 'patch',
HTTPVerb.delete: 'delete',
HTTPVerb.options: 'options',
};
const _$ContentTypeEnumMap = {

View File

@@ -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(),

View File

@@ -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;

View File

@@ -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',
);

View File

@@ -253,3 +253,9 @@ const requestModelPost13 = RequestModel(
apiType: APIType.rest,
httpRequestModel: httpRequestModelPost13,
);
const requestModelOptions1 = RequestModel(
id: 'options1',
apiType: APIType.rest,
httpRequestModel: httpRequestModelOptions1,
);

View File

@@ -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);
});
}