mirror of
https://github.com/foss42/apidash.git
synced 2025-06-21 23:00:44 +08:00
Merge pull request #596 from KKSurendran06/feat/env-var-text-body
Feat/env var text body
This commit is contained in:
@ -86,6 +86,11 @@ HttpRequestModel substituteHttpRequestModel(
|
|||||||
value: substituteVariables(param.value, envMap, activeEnvironmentId),
|
value: substituteVariables(param.value, envMap, activeEnvironmentId),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
body: substituteVariables(
|
||||||
|
httpRequestModel.body,
|
||||||
|
envMap,
|
||||||
|
activeEnvironmentId,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return newRequestModel;
|
return newRequestModel;
|
||||||
}
|
}
|
||||||
|
@ -211,10 +211,12 @@ void main() {
|
|||||||
NameValueModel(name: "num", value: "{{num}}"),
|
NameValueModel(name: "num", value: "{{num}}"),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String?, List<EnvironmentVariableModel>> envMap = {
|
Map<String?, List<EnvironmentVariableModel>> envMap = {
|
||||||
kGlobalEnvironmentId: globalVars,
|
kGlobalEnvironmentId: globalVars,
|
||||||
"activeEnvId": activeEnvVars,
|
"activeEnvId": activeEnvVars,
|
||||||
};
|
};
|
||||||
|
|
||||||
String? activeEnvironmentId = "activeEnvId";
|
String? activeEnvironmentId = "activeEnvId";
|
||||||
const expected = HttpRequestModel(
|
const expected = HttpRequestModel(
|
||||||
url: "api.apidash.dev/humanize/social",
|
url: "api.apidash.dev/humanize/social",
|
||||||
@ -227,7 +229,10 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
substituteHttpRequestModel(
|
substituteHttpRequestModel(
|
||||||
httpRequestModel, envMap, activeEnvironmentId),
|
httpRequestModel,
|
||||||
|
envMap,
|
||||||
|
activeEnvironmentId,
|
||||||
|
),
|
||||||
expected);
|
expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -260,6 +265,40 @@ void main() {
|
|||||||
httpRequestModel, envMap, activeEnvironmentId),
|
httpRequestModel, envMap, activeEnvironmentId),
|
||||||
expected);
|
expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
"Testing substituteHttpRequestModel with environment variables in body",
|
||||||
|
() {
|
||||||
|
const httpRequestModel = HttpRequestModel(
|
||||||
|
url: "{{url}}/humanize/social",
|
||||||
|
headers: [
|
||||||
|
NameValueModel(name: "Authorization", value: "Bearer {{token}}"),
|
||||||
|
],
|
||||||
|
params: [
|
||||||
|
NameValueModel(name: "num", value: "{{num}}"),
|
||||||
|
],
|
||||||
|
body: "The API key is {{token}} and the number is {{num}}",
|
||||||
|
);
|
||||||
|
Map<String?, List<EnvironmentVariableModel>> envMap = {
|
||||||
|
kGlobalEnvironmentId: globalVars,
|
||||||
|
"activeEnvId": activeEnvVars,
|
||||||
|
};
|
||||||
|
String? activeEnvironmentId = "activeEnvId";
|
||||||
|
const expected = HttpRequestModel(
|
||||||
|
url: "api.apidash.dev/humanize/social",
|
||||||
|
headers: [
|
||||||
|
NameValueModel(name: "Authorization", value: "Bearer token"),
|
||||||
|
],
|
||||||
|
params: [
|
||||||
|
NameValueModel(name: "num", value: "8940000"),
|
||||||
|
],
|
||||||
|
body: "The API key is token and the number is 8940000",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
substituteHttpRequestModel(
|
||||||
|
httpRequestModel, envMap, activeEnvironmentId),
|
||||||
|
expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group("Testing getEnvironmentTriggerSuggestions function", () {
|
group("Testing getEnvironmentTriggerSuggestions function", () {
|
||||||
|
Reference in New Issue
Block a user