Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality to pass down the header to bot #1848

Merged
merged 14 commits into from
Jan 21, 2024
Prev Previous commit
Next Next commit
Corrected test case and passed default argument
  • Loading branch information
Shubham Sharma committed Jan 15, 2024
commit a3e0a688829040fccb56f1d9af603f17d40fdd5c
6 changes: 3 additions & 3 deletions test/unit/utils/genrateCloudFlare.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const { genrateCloudFlareHeaders } = require("../../../utils/discord-actions");
describe("genrateCloudFlareHeaders", function () {
it("generates headers with prop Content-Type and Authorization", function () {
const data = genrateCloudFlareHeaders();
expect(data["Content-Type"]).to.be("application/json");
expect(data["Content-Type"]).to.be.eq("application/json");
expect(data).to.include("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9");
});
it("generates headers with prop Content-Type and Authorization and X-Audit-Log-Reason when id and userName is passed", function () {
const data = genrateCloudFlareHeaders({ id: "is", userName: "userName" });
expect(data["Content-Type"]).to.be("application/json");
expect(data["Content-Type"]).to.be.eq("application/json");
expect(data.Authorization).to.include("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9");
expect(data["X-Audit-Log-Reason"]).to.be("Action initiator's username=>userName and id=id");
expect(data["X-Audit-Log-Reason"]).to.be.eq("Action initiator's username=>userName and id=id");
});
});
2 changes: 1 addition & 1 deletion utils/discord-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const generateAuthTokenForCloudflare = () => {
});
return authToken;
};
const genrateCloudFlareHeaders = ({ userName, id }) => {
const genrateCloudFlareHeaders = ({ userName, id } = {}) => {
const authToken = generateAuthTokenForCloudflare();
const headers = {
"Content-Type": "application/json",
Expand Down
Loading