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

Remove dev feature flag for GET /logs API #2149

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions controllers/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ const fetchLogs = async (req, res) => {
const fetchAllLogs = async (req, res) => {
const { query } = req;
try {
if (query.dev !== "true") {
return res.boom.badRequest("Please use feature flag to make this request!");
}
const logs = await logsQuery.fetchAllLogs(query);
if (logs.length === 0) {
return res.status(204).send();
}
const { allLogs, next, prev, page } = logs;
if (page) {
const pageLink = `/logs?page=${page}&dev=${query.dev}`;
const pageLink = `/logs?page=${page}`;
return res.status(200).json({
message: ALL_LOGS_FETCHED_SUCCESSFULLY,
data: allLogs,
Expand Down
34 changes: 9 additions & 25 deletions test/integration/logs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("/logs", function () {
it("should return 401 if user is not logged in", function (done) {
chai
.request(app)
.get("/logs?dev=true")
.get("/logs")
.end(function (err, res) {
if (err) {
return done(err);
Expand All @@ -97,26 +97,10 @@ describe("/logs", function () {
});
});

it("should return 400, if user has access and dev flag is not", function (done) {
chai
.request(app)
.get("/logs")
.set("cookie", `${cookieName}=${superUserToken}`)
.end(function (err, res) {
if (err) {
return done(err);
}
expect(res).to.have.status(400);
expect(res.body.error).to.equal("Bad Request");
expect(res.body.message).to.equal(`Please use feature flag to make this request!`);
return done();
});
});

it("should return all Logs", function (done) {
chai
.request(app)
.get("/logs?dev=true")
.get("/logs")
.set("cookie", `${cookieName}=${superUserToken}`)
.end(function (err, res) {
if (err) {
Expand All @@ -132,7 +116,7 @@ describe("/logs", function () {
it("should return all formatted Logs", function (done) {
chai
.request(app)
.get("/logs?dev=true&format=feed")
.get("/logs?format=feed")
.set("cookie", `${cookieName}=${superUserToken}`)
.end(function (err, res) {
if (err) {
Expand All @@ -159,7 +143,7 @@ describe("/logs", function () {
it("should return logs of type = extensionRequests", function (done) {
chai
.request(app)
.get("/logs?type=extensionRequests&dev=true")
.get("/logs?type=extensionRequests")
.set("cookie", `${cookieName}=${superUserToken}`)
.end((err, res) => {
if (err) {
Expand All @@ -174,7 +158,7 @@ describe("/logs", function () {
it("if no logs are present, should return valid response", function (done) {
chai
.request(app)
.get("/logs?type=REQUEST_CREATED1&dev=true")
.get("/logs?type=REQUEST_CREATED1")
.set("cookie", `${cookieName}=${superUserToken}`)
.end((err, res) => {
if (err) {
Expand All @@ -189,31 +173,31 @@ describe("/logs", function () {
it("should return data if page param is passed in the quey", function (done) {
chai
.request(app)
.get("/logs?page=1&dev=true&size=3")
.get("/logs?page=1&size=3")
.set("cookie", `${cookieName}=${superUserToken}`)
.end(function (err, res) {
if (err) {
return done(err);
}
expect(res.body.message).to.equal("All Logs fetched successfully");
expect(res.body.data).to.lengthOf(3);
expect(res.body.page).to.equal("/logs?page=2&dev=true");
expect(res.body.page).to.equal("/logs?page=2");
return done();
});
});

it("should return valid paginated link", function (done) {
chai
.request(app)
.get("/logs?dev=true&size=3")
.get("/logs?size=3")
.set("cookie", `${cookieName}=${superUserToken}`)
.end(function (err, res) {
if (err) {
return done(err);
}
expect(res.body.message).to.equal("All Logs fetched successfully");
expect(res.body.data).to.lengthOf(3);
expect(res.body.next).to.contain("/logs?dev=true&size=3&next=");
expect(res.body.next).to.contain("/logs?size=3&next=");
return done();
});
});
Expand Down
Loading