Skip to content

Commit

Permalink
Merge branch 'release-4.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Jul 18, 2018
2 parents c6570ee + 9e5db78 commit f68f080
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [4.0.1] (2018-07-18)

### Fixed

- [#457](https://github.com/dadi/api/issues/457): reinstate `slug` property in /api/collections endpoint
- [#460](https://github.com/dadi/api/pull/460): use correct permissions and status code when a role is revoked from a client

## [4.0.0] (2018-07-11)

### Added
Expand Down
7 changes: 3 additions & 4 deletions dadi/lib/controller/clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ Clients.prototype.deleteRole = function (req, res, next) {
// they have the role they are trying to remove.
if (!model.isAdmin(req.dadiApiClient)) {
return model.get(req.dadiApiClient.clientId).then(({results}) => {
let requestingClientHasRole = Boolean(
results.find(dbRole => dbRole.name === role)
)
let user = results[0]
let requestingClientHasRole = user.roles && user.roles.includes(role)

return requestingClientHasRole
})
Expand All @@ -129,7 +128,7 @@ Clients.prototype.deleteRole = function (req, res, next) {
return help.sendBackJSON(404, res, next)(null)
}

help.sendBackJSON(200, res, next)(null, {results})
help.sendBackJSON(204, res, next)(null, {results})
}).catch(this.handleError(res, next))
}

Expand Down
2 changes: 1 addition & 1 deletion dadi/lib/controller/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Collections.prototype.get = function (req, res, next) {
version: parts[1],
database: parts[2],
name: (model.settings && model.settings.displayName) || model.name,
slug: model.slug,
slug: model.name,
path: key
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dadi/api",
"version": "4.0.0",
"version": "4.0.1",
"main": "main.js",
"scripts": {
"create-client": "cd ../../.. && node ./node_modules/@dadi/api/utils/create-client.js",
Expand Down
34 changes: 34 additions & 0 deletions test/acceptance/collections-endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,38 @@ describe('Collections endpoint', function () {
})
})
})

it('should return all the collections if the requesting client has admin access', done => {
help.getBearerTokenWithPermissions({
accessType: 'admin'
}).then(token => {
client
.get(`/api/collections`)
.set('content-type', 'application/json')
.set('Authorization', `Bearer ${token}`)
.end((err, res) => {
let allCollections = help.getCollectionMap()

res.body.collections.length.should.eql(
Object.keys(allCollections).length
)

Object.keys(allCollections).forEach(key => {
let match = res.body.collections.some(collection => {
collection.version.should.be.String
collection.database.should.be.String
collection.name.should.be.String
collection.slug.should.be.String
collection.path.should.be.String

return collection.path === key
})

match.should.eql(true)
})

done()
})
})
})
})

0 comments on commit f68f080

Please sign in to comment.