mufidu / booku

0 stars 1 forks source link

Sweep: Use .env for credentials in test #115

Closed mufidu closed 5 months ago

mufidu commented 5 months ago

Details

Currently the email and password are exposed. Use variable from .env instead in all tests in the test folder. Use the same account for all tests except delete user (use different email and password for login and register). Use dotenv like in app.js.

Checklist - [X] Modify `test/profile.test.js` ✓ https://github.com/mufidu/booku/commit/9d86af0d2e11e4d541dc712abb51fa269b80c497 [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/profile.test.js) - [X] Running GitHub Actions for `test/profile.test.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/profile.test.js) - [X] Modify `test/app.test.js` ✓ https://github.com/mufidu/booku/commit/9c288e304f50f99e1a8a98ee390f9f052400f788 [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/app.test.js) - [X] Running GitHub Actions for `test/app.test.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/app.test.js) - [X] Modify `test/booksSearch.test.js` ✓ https://github.com/mufidu/booku/commit/ef16ffc0c1018840b8f53fd5c644130d40b83424 [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/booksSearch.test.js) - [X] Running GitHub Actions for `test/booksSearch.test.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/booksSearch.test.js) - [X] Modify `test/bookCategory.test.js` ✓ https://github.com/mufidu/booku/commit/85aeccfe64be92a05414bf00f71db9b10318351d [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/bookCategory.test.js) - [X] Running GitHub Actions for `test/bookCategory.test.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/bookCategory.test.js) - [X] Modify `test/booksByAuthor.test.js` ✓ https://github.com/mufidu/booku/commit/b3022745fd620124148cf526536797d598e3cb9e [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/booksByAuthor.test.js) - [X] Running GitHub Actions for `test/booksByAuthor.test.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/test/booksByAuthor.test.js) - [X] Create `Instructions for .env setup` ✓ https://github.com/mufidu/booku/commit/3882dc49a848ac9eadeca58927cc06d5464a5f8f [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/Instructions for .env setup) - [X] Running GitHub Actions for `Instructions for .env setup` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/use_env_for_credentials_in_test/Instructions for .env setup)
sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #118

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: ec98084cc6)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/mufidu/booku/blob/0bd17ce471c9dde0a2a33fcced6c6b85980e7561/test/profile.test.js#L1-L64 https://github.com/mufidu/booku/blob/0bd17ce471c9dde0a2a33fcced6c6b85980e7561/test/app.test.js#L1-L99 https://github.com/mufidu/booku/blob/0bd17ce471c9dde0a2a33fcced6c6b85980e7561/test/booksSearch.test.js#L1-L88 https://github.com/mufidu/booku/blob/0bd17ce471c9dde0a2a33fcced6c6b85980e7561/test/bookCategory.test.js#L1-L78 https://github.com/mufidu/booku/blob/0bd17ce471c9dde0a2a33fcced6c6b85980e7561/test/booksByAuthor.test.js#L1-L58 https://github.com/mufidu/booku/blob/0bd17ce471c9dde0a2a33fcced6c6b85980e7561/app.js#L1-L54

Step 2: ⌨️ Coding

--- 
+++ 
@@ -2,6 +2,7 @@
 const chaiHttp = require('chai-http');
 const app = require('../app');
 const expect = chai.expect;
+require('dotenv').config();

 chai.use(chaiHttp);

@@ -11,7 +12,7 @@
   before(async function () {
     const loginResponse = await chai.request(app)
       .post('/auth/login')
-      .send({ email: 'mufid.to@gmail.com', password: 'password' });
+      .send({ email: process.env.TEST_EMAIL, password: process.env.TEST_PASSWORD });
     token = loginResponse.body.jwt;
   });

Ran GitHub Actions for 9d86af0d2e11e4d541dc712abb51fa269b80c497:

--- 
+++ 
@@ -2,6 +2,7 @@
 const chaiHttp = require("chai-http");
 const app = require("../app");
 const Book = require("../models/book");
+require('dotenv').config();

 chai.use(chaiHttp);
 const { expect } = chai;
@@ -12,7 +13,7 @@
     try {
         const res = await chai.request(app)
             .post("/auth/login")
-            .send({ email: "mufid.to@gmail.com", password: "password" });
+            .send({ email: process.env.TEST_EMAIL, password: process.env.TEST_PASSWORD });
         token = res.body.jwt;
     } catch (error) {
         console.error("Login failed", error);

Ran GitHub Actions for 9c288e304f50f99e1a8a98ee390f9f052400f788:

--- 
+++ 
@@ -3,13 +3,14 @@
 const server = require('../app');
 const should = chai.should();
 chai.use(chaiHttp);
+require('dotenv').config();

 let token;

 before(done => {
   chai.request(server)
     .post('/auth/login')
-    .send({ email: 'mufid.to@gmail.com', password: 'password' })
+    .send({ email: process.env.TEST_EMAIL, password: process.env.TEST_PASSWORD })
     .end((err, res) => {
       token = res.body.jwt;
       done();

Ran GitHub Actions for ef16ffc0c1018840b8f53fd5c644130d40b83424:

--- 
+++ 
@@ -2,6 +2,7 @@
 const chaiHttp = require('chai-http');
 const server = require('../app');
 const expect = chai.expect;
+require('dotenv').config();

 chai.use(chaiHttp);

@@ -10,7 +11,7 @@
 before(done => {
     chai.request(server)
         .post('/auth/login')
-        .send({ email: 'mufid.to@gmail.com', password: 'password' })
+        .send({ email: process.env.TEST_EMAIL, password: process.env.TEST_PASSWORD })
         .end((err, res) => {
             token = res.body.jwt;
             done();

Ran GitHub Actions for 85aeccfe64be92a05414bf00f71db9b10318351d:

--- 
+++ 
@@ -2,6 +2,7 @@
 const chaiHttp = require('chai-http');
 const server = require('../app');
 const expect = chai.expect;
+require('dotenv').config();

 chai.use(chaiHttp);

@@ -10,7 +11,7 @@
 before(done => {
   chai.request(server)
     .post('/auth/login')
-    .send({ email: 'mufid.to@gmail.com', password: 'password' })
+    .send({ email: process.env.TEST_EMAIL, password: process.env.TEST_PASSWORD })
     .end((err, res) => {
       token = res.body.jwt;
       done();

Ran GitHub Actions for b3022745fd620124148cf526536797d598e3cb9e:

Ran GitHub Actions for 3882dc49a848ac9eadeca58927cc06d5464a5f8f:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/use_env_for_credentials_in_test.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.