Skip to content
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
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Unit Tests
if: type = pull_request OR type = push AND branch =~ /^master|[0-9]+-(dev|stable)$/ OR type = cron
language: node_js
node_js: 8
node_js: 6

env:
# Codecov token
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
name: Integration Tests
if: type = pull_request OR type = push AND branch =~ /^master|[0-9]+-(dev|stable)$/ OR type = cron
language: node_js
node_js: 8
node_js: 6

addons:
apt:
Expand All @@ -69,7 +69,7 @@ jobs:
name: Documentation Tests
if: type = pull_request OR type = push AND branch =~ /^master|[0-9]+-(dev|stable)$/ OR type = cron
language: node_js
node_js: 8
node_js: 10

before_script:
- sudo apt-get install libgconf-2-4
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
if: tag IS present AND type != cron
sudo: false
language: node_js
node_js: 8
node_js: 6

addons:
apt:
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
if: type = push && branch =~ /^[0-9]+-dev$/
sudo: false
language: node_js
node_js: 8
node_js: 6

addons:
apt:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
name: security#updateProfile
description: update profile
description: updates a security profile definition
hooks:
before: >
curl -H "Content-type: application/json" -d '{
"policies": []
}' kuzzle:7512/profiles/myProfile/_create
after: curl -XDELETE kuzzle:7512/profiles/myProfile
before:
- >
curl -H "Content-type: application/json" -d '{
"policies": []
}' kuzzle:7512/profiles/myProfile/_create
- >
curl -H "Content-type: application/json" -d '{
"controllers": {
"*": {
"actions": {
"*": true
}
}
}
}' kuzzle:7512/roles/privileged/_create
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to create the role beforehand because now kuzzle refuses to create a profile based on a non-existing role

after:
- curl -XDELETE kuzzle:7512/profiles/myProfile?refresh=wait_for
- curl -XDELETE kuzzle:7512/roles/privileged
template: default
expected: '^ { roleId: ''privileged'', restrictedTo: \[Array\] } \] }$'
61 changes: 29 additions & 32 deletions doc/6/controllers/security/update-role/snippets/update-role.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
try {
const response = await kuzzle.security.updateRole(
'read-only',
{
controllers: {
auth: {
actions: {
getCurrentUser: true,
getMyCredentials: true,
getMyRights: true,
logout: true
}
},
collection: {
actions: {
getMapping: true,
list: true
}
},
document: {
actions: {
count: true,
get: true,
mGet: true,
scroll: true,
search: true
}
},
index: {
actions: {
list: true
}
const response = await kuzzle.security.updateRole('read-only', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await

controllers: {
auth: {
actions: {
getCurrentUser: true,
getMyCredentials: true,
getMyRights: true,
logout: true
}
},
collection: {
actions: {
getMapping: true,
list: true
}
},
document: {
actions: {
count: true,
get: true,
mGet: true,
scroll: true,
search: true
}
},
index: {
actions: {
list: true
}
}
}
);
});

console.log(response);
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ hooks:
before: >
curl -f -H "Content-type: application/json" -d '{
"controllers": {
"*": {
"auth": {
"actions": {
"*": false
"login": true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ hooks:
before:
after:
template: default
expected: ^(Kuzzle Server configuration:) {("dump":{.*}),("limits":{.*}),("plugins":{.*}),("queues":{.*}),("repositories":{.*}),("server":{.*}),("services":{.*}),("stats":{.*}),("validation":{.*}),("_":.*),("internal":{.*}),("version":"[0-9]\.[0-9]\.[0-9]")}$

expected: ^(Kuzzle Server configuration:) {("dump":{.*}),("limits":{.*}),("plugins":{.*}),("queues":{.*}),("repositories":{.*}),("server":{.*}),("services":{.*}),("stats":{.*}),("validation":{.*}),("_":.*),("internal":{.*}),("version":"[0-9]+\.[0-9]+\.[0-9]+")}$
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the change here is not immediately obvious: this fixes the erroneous version regex that fails now because, kuzzle being in 1.10, the minor version has 2 digits

sdk: js
version: 6
2 changes: 1 addition & 1 deletion doc/6/controllers/server/info/snippets/info.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ hooks:
before:
after:
template: default
expected: "^Kuzzle Server information: {\"serverInfo\":{\"kuzzle\":{\"version\":\"[0-9]\\.[0-9]\\.[0-9]\",\"api\":{.*"
expected: "^Kuzzle Server information: {\"serverInfo\":{\"kuzzle\":{\"version\":\"[0-9]+\\.[0-9]+\\.[0-9]+\",\"api\":{.*"
sdk: js
version: 6
64 changes: 35 additions & 29 deletions features/steps/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ const
should = require('should'),
retry = require('retry');

Given('I log in as {string}:{string}', async function (username, password) {
try {
this.jwt = await this.kuzzle.auth.login('local', {
username,
password
Given('I log in as {string}:{string}', function (username, password) {
return this.kuzzle.auth.login('local', { username, password })
.then(jwt => {
this.jwt = jwt;
})
.catch(error => {
this.jwt = 'invalid';
this.error = error;
});
this.error = null;
}
catch (error) {
this.jwt = 'invalid';
this.error = error;
}
});

When('I logout', async function () {
await this.kuzzle.auth.logout();
When('I logout', function () {
return this.kuzzle.auth.logout();
});

When('I refresh the JWT', function (cb) {
Expand All @@ -27,11 +24,16 @@ When('I refresh the JWT', function (cb) {
// we have to wait for at least 1s: if we ask Kuzzle to refresh a JWT that
// has been generated during the same second, then the new JWT will be
// identical to the one being refreshed
setTimeout(async () => {
const token = await this.kuzzle.auth.refreshToken();
this.jwt = token.jwt;
cb();
}, 1000);
setTimeout(
() => {
this.kuzzle.auth.refreshToken()
.then(token => {
this.jwt = token.jwt;
cb();
})
.catch(err => cb(err));
},
1000);
});

Then('the previous JWT is now invalid', function (cb) {
Expand All @@ -56,19 +58,23 @@ Then('the previous JWT is now invalid', function (cb) {
});
});

Then(/^the JWT is (in)?valid$/, async function (not) {
const response = await this.kuzzle.auth.checkToken(this.jwt);

if (not) {
should(response.valid).be.false();
}
else {
should(response.valid).be.true();
}
Then(/^the JWT is (in)?valid$/, function (not) {
return this.kuzzle.auth.checkToken(this.jwt)
.then(response => {
if (not) {
should(response.valid).be.false();
}
else {
should(response.valid).be.true();
}
});
});

Given('I get my rights', async function () {
this.rights = await this.kuzzle.auth.getMyRights();
Given('I get my rights', function () {
return this.kuzzle.auth.getMyRights()
.then(rights => {
this.rights = rights;
});
});

Then('I have a vector with {int} rights', function (nbRights) {
Expand Down
Loading