Skip to content

Commit 4ccf137

Browse files
committed
fix: fix user db not filtering users by query
1 parent 96a35aa commit 4ccf137

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

packages/git-proxy-cli/test/testCli.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,12 @@ describe('test git-proxy-cli', function () {
645645

646646
describe('test git-proxy-cli :: git push administration', function () {
647647
const pushId = `0000000000000000000000000000000000000000__${Date.now()}`;
648+
const gitAccount = 'testGitAccount1';
648649

649650
before(async function () {
650651
await helper.addRepoToDb(TEST_REPO_CONFIG);
651-
await helper.addGitPushToDb(pushId, TEST_REPO);
652+
await helper.addUserToDb('testuser1', 'testpassword', '[email protected]', gitAccount);
653+
await helper.addGitPushToDb(pushId, TEST_REPO, gitAccount);
652654
});
653655

654656
it('attempt to ls should list existing push', async function () {

packages/git-proxy-cli/test/testCliUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,15 @@ async function addRepoToDb(newRepo, debug = false) {
170170
* @param {string} repo The repository of the git push.
171171
* @param {boolean} debug Flag to enable logging for debugging.
172172
*/
173-
async function addGitPushToDb(id, repo, debug = false) {
173+
async function addGitPushToDb(id, repo, user = null, debug = false) {
174174
const action = new actions.Action(
175175
id,
176176
'push', // type
177177
'get', // method
178178
Date.now(), // timestamp
179179
repo,
180180
);
181+
action.user = user;
181182
const step = new steps.Step(
182183
'authBlock', // stepName
183184
false, // error

src/db/file/users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ exports.updateUser = function (user) {
7878
exports.getUsers = function (query) {
7979
if (!query) query = {};
8080
return new Promise((resolve, reject) => {
81-
db.find({}, (err, docs) => {
81+
db.find(query, (err, docs) => {
8282
if (err) {
8383
reject(err);
8484
} else {

0 commit comments

Comments
 (0)