Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
merging master.
Browse files Browse the repository at this point in the history
  • Loading branch information
elixic committed Mar 17, 2015
2 parents 3b7eb23 + 1735990 commit 2523cb6
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 179 deletions.
9 changes: 0 additions & 9 deletions app/server/apps/repos/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ module.exports = {
send.json
]
},
read: {
method: 'GET',
path: '/repos/:id',
middleware: [
auth.isAuthenticated,
repos.readRepo,
send.json
]
},
editUserPermission: {
method: 'PUT',
path: '/repos/:id/users/:username/permissions/:permission',
Expand Down
9 changes: 0 additions & 9 deletions app/server/apps/users/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ module.exports = {
send.json
]
},
read: {
method: 'GET',
path: '/users/:username',
middleware: [
auth.isAuthenticated,
users.readUser,
send.json
]
},
editRepoPermission: {
method: 'PUT',
path: '/users/:username/repos/:id/permissions/:permission',
Expand Down
4 changes: 0 additions & 4 deletions app/server/components/repositories/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ module.exports = {

getRepos () {
return repoUtil.getGithubRepos();
},

getRepo (repoId) {
return repoUtil.getGithubRepo(repoId);
}

};
15 changes: 0 additions & 15 deletions app/server/components/repositories/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,9 @@ module.exports = {
});
},

getUser (username) {
return userUtil.getGithubUser(username);
},

getPermissions (repoId, users) {
return permUtil.getPermissionMap().then(map => {
let userMap = map[repoId];
users.forEach(user => {
user.permission = userMap[user.username] || permUtil.getDefaultPermissions();
});
return users;
});
},

isOrgMember (username) {
return userUtil.isOrgMember(username).then(function (data) {
return "204 No Content" === data.meta.success;
});
}

};
8 changes: 0 additions & 8 deletions app/server/components/repositories/util/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ module.exports = {
getGithubRepos () {
let args = provider.getDefaultListArgs();
return provider.github.getRepos(args).then(repos => repos.map(repo => convertGithubRepo(repo)));
},

getGithubRepo (repoId) {
let args = provider.getDefaultItemArgs();
return provider.github.getRepos(args).then(repos => {
let id = parseInt(repoId, 10);
return convertGithubRepo(repos.find(repo => repo.id === id));
});
}

};
45 changes: 3 additions & 42 deletions app/server/it/TestRepos.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,9 @@ describe('Repo model HTTP requests', function () {
chai.assert.ok(items[0].id);
});

it('repo has links', () => {
chai.assert.ok(items[0].links.length > 0);
});

});

describe('pull', () => {

let item,
statusCode;

before((done) => {
util.get('/repos/1').then((result) => {
item = JSON.parse(result.body);
statusCode = result.statusCode;
done();
});
});

it('returns a 200', () => {
chai.assert.equal(statusCode, 200);
});

it('returns a repo', () => {
chai.assert.ok(item.id);
//TODO: use authenticated user to check for links
it('repo has no links', () => {
chai.assert.isUndefined(items[0].links);
});

});
Expand All @@ -103,21 +81,4 @@ describe('Repo model HTTP requests', function () {

});

describe('removeUserPermission', () => {

let statusCode;

before((done) => {
util.del('/repos/1/users/testuser1').then((result) => {
statusCode = result.statusCode;
done();
});
});

it('returns a 204', () => {
chai.assert.equal(statusCode, 204);
});

});

});
45 changes: 3 additions & 42 deletions app/server/it/TestUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,9 @@ describe('User model HTTP requests', function () {
chai.assert.ok(items[0].username);
});

it('user has links', () => {
chai.assert.ok(items[0].links.length > 0);
});

});

describe('pull', () => {

let item,
statusCode;

before((done) => {
util.get('/users/testuser1').then((result) => {
item = JSON.parse(result.body);
statusCode = result.statusCode;
done();
});
});

it('returns a 200', () => {
chai.assert.equal(statusCode, 200);
});

it('returns a user', () => {
chai.assert.ok(item.username);
//TODO: use authenticated user to check for links
it('user has no links', () => {
chai.assert.isUndefined(items[0].links);
});

});
Expand All @@ -103,21 +81,4 @@ describe('User model HTTP requests', function () {

});

describe('removeRepoPermission', () => {

let statusCode;

before((done) => {
util.del('/users/testuser1/repos/1').then((result) => {
statusCode = result.statusCode;
done();
});
});

it('returns a 204', () => {
chai.assert.equal(statusCode, 204);
});

});

});
11 changes: 0 additions & 11 deletions app/server/middleware/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,5 @@ module.exports = {
} else {
next();
}
},

readRepo (req, res, next) {
debug('getting repo [' + req.path + ']');
debug('params:' + JSON.stringify(req.params, null, 2));

let repoId = req.params.id;
repoRepository.getRepo(repoId).then(repo => {
req.entity = repo;
next();
}).catch(err => next(err));
}
};
11 changes: 0 additions & 11 deletions app/server/middleware/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,5 @@ module.exports = {
} else {
next();
}
},

readUser (req, res, next) {
debug('getting user [' + req.path + ']');
debug('params:' + JSON.stringify(req.params, null, 2));

let username = req.params.username;
userRepository.getUser(username).then(user => {
req.entity = user;
next();
}).catch(err => next(err));
}
};
15 changes: 4 additions & 11 deletions documents/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,24 @@ This is a draft of the operations available to meet the initial views of the app

GET /users[?permission_repo=:id]
returns User[]
2. Get details for a user

GET /users/:username
returns User

3. Add/update/remove repo permissions for a user
2. Add/update/remove repo permissions for a user

PUT /users/:username/repos/:id/permissions/:permission
returns null, 204

4. Get list of repos. If permission_user is specified, the "permission" flag on each repo will be present, reporting the access available for that user.
3. Get list of repos. If permission_user is specified, the "permission" flag on each repo will be present, reporting the access available for that user.

GET /repos[?permission_user=:username]
returns Repo[]
5. Get details for a repo

GET /repos/:id
returns Repo
6. Add/update/remove user permissions for a repo
4. Add/update/remove user permissions for a repo

PUT /repos/:id/users/:username/permissions/:permission
returns null, 204


Note that 3/6 are effectively aliases to each other, suitable for different views.
Note that 2/4 are effectively aliases to each other, suitable for different views.

Also note that some PUT operations have no body, as the URL contains sufficient data. See [GitHub documentation](https://developer.github.com/v3/#http-verbs).

Expand Down
25 changes: 8 additions & 17 deletions documents/ServiceMapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,15 @@ The following details the node-github methods that will be called by permissive.
1. Return the mapping for the requested repo


### 2 Get details for a user
1. Get the user data (user.getFrom)


### 3 Add repo permission for a user
### 2 Add repo permission for a user
1. Get a list of repos in the organization (repos.getFromOrg)
1. Find the appropriate repo
1. Get a list of teams in the organization (orgs.getTeams)
1. Find the appropriate team (permission)
1. Add the user to the team (orgs.addTeamMember)


### 3a Update repo permission for a user
### 2a Update repo permission for a user
1. Get a list of repos in the organization (repos.getFromOrg)
1. Find the appropriate repo
1. Get a list of teams in the organization (orgs.getTeams)
Expand All @@ -68,7 +64,7 @@ The following details the node-github methods that will be called by permissive.
1. Add the user to the team (orgs.addTeamMember)


### 3b Remove repo access for a user
### 2b Remove repo access for a user
1. Get a list of repos in the organization (repos.getFromOrg)
1. Find the appropriate repo
1. Get a list of teams in the organization (orgs.getTeams)
Expand All @@ -77,11 +73,11 @@ The following details the node-github methods that will be called by permissive.
1. If the user is on the team, remove them (orgs.deleteTeamMember)


### 4 Get list of repos
### 3 Get list of repos
1. Get a list of repos in the organization (repos.getFromOrg)


### 4a Get a list of repos with permission for a specific user
### 3a Get a list of repos with permission for a specific user
1. Get a list of members in the organization (orgs.getMembers)
1. For each member
1. Get the user data (user.getFrom)
Expand All @@ -95,20 +91,15 @@ The following details the node-github methods that will be called by permissive.
1. Return a mapping for the requested user


### 5 Get details for a repo
1. Get a list of repos in the organization (repos.getFromOrg)
1. Find the appropriate repo


### 6 Add user permission for a repo
### 5 Add user permission for a repo
1. Get a list of repos in the organization (repos.getFromOrg)
1. Find the appropriate repo
1. Get a list of teams in the organization (orgs.getTeams)
1. Find the users new team (permission)
1. Add the user to the team (orgs.addTeamMember)


### 6a Update user permission for a repo
### 5a Update user permission for a repo
1. Get a list of repos in the organization (repos.getFromOrg)
1. Find the appropriate repo
1. Get a list of teams in the organization (orgs.getTeams)
Expand All @@ -118,7 +109,7 @@ The following details the node-github methods that will be called by permissive.
1. Add the user to the team (orgs.addTeamMember)


### 6b Remove user access to a repo
### 5b Remove user access to a repo
1. Get a list of repos in the organization (repos.getFromOrg)
1. Find the appropriate repo
1. Get a list of teams in the organization (orgs.getTeams)
Expand Down

0 comments on commit 2523cb6

Please sign in to comment.