mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
add user api feature file updated
This commit is contained in:
parent
a248921d73
commit
f7dab981c7
|
|
@ -64,4 +64,15 @@ Feature: Add user
|
|||
| swi@ | s$5^2 |
|
||||
| g!!@%ui | नेपाली |
|
||||
| swikriti@h | सिमप्ले $%#?&@name.txt |
|
||||
| !@#$%^&*()-_+ | España§àôœ€ |
|
||||
| !@#$%^&*()-_+ | España§àôœ€ |
|
||||
|
||||
Scenario: Non-admin user with api key adds user
|
||||
Given the admin has created the following users
|
||||
| login | last name | password | api_key |
|
||||
| Harry | Potter | hello123 | harrypotter |
|
||||
When the non-admin user "Harry" with password "hello123" creates user with following details using API
|
||||
| last name | Potter |
|
||||
| login | Ginny |
|
||||
| password | password |
|
||||
Then the response status code should be "200"
|
||||
And user with login "Ginny" should exist
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ const {Given, When, Then} = require('cucumber');
|
|||
const {client} = require('nightwatch-api');
|
||||
const fetch = require('node-fetch');
|
||||
const assert = require('assert');
|
||||
const {getDolApiKey} = require('../setup');
|
||||
let Login = {};
|
||||
|
||||
Given('the administrator has browsed to the new users page', function () {
|
||||
|
|
@ -56,11 +57,20 @@ Then('the response message should be {string}', function (expectedResponseMessag
|
|||
return getResponseMessage(expectedResponseMessage);
|
||||
});
|
||||
|
||||
const createUserRequest = function (login, lastname, password, api_key = null) {
|
||||
When('the non-admin user {string} with password {string} creates user with following details using API', async function (login, password, dataTable) {
|
||||
const userDolApikey = await getDolApiKey(login, password);
|
||||
return userCreatesUserWithApi(dataTable, userDolApikey);
|
||||
});
|
||||
|
||||
const createUserRequest = function (login, lastname, password, api_key = null, dolApiKey = null) {
|
||||
const header = {};
|
||||
const url = client.globals.backend_url + 'api/index.php/users';
|
||||
header['Accept'] = 'application/json';
|
||||
header['DOLAPIKEY'] = client.globals.dolApiKey;
|
||||
if (dolApiKey === null) {
|
||||
header['DOLAPIKEY'] = client.globals.dolApiKey;
|
||||
} else {
|
||||
header['DOLAPIKEY'] = dolApiKey;
|
||||
}
|
||||
header['Content-Type'] = 'application/json';
|
||||
return fetch(url, {
|
||||
method: 'POST',
|
||||
|
|
@ -84,6 +94,14 @@ const adminCreatesUserWithAPI = function (dataTable) {
|
|||
});
|
||||
};
|
||||
|
||||
const userCreatesUserWithApi = function (dataTable, dolApiKey) {
|
||||
const userDetails = dataTable.rowsHash();
|
||||
return createUserRequest(userDetails['login'], userDetails['last name'], userDetails['password'], null, dolApiKey)
|
||||
.then((res) => {
|
||||
client.globals.response = res;
|
||||
});
|
||||
};
|
||||
|
||||
const adminHasCreatedUser = async function (dataTable) {
|
||||
const userDetails = dataTable.hashes();
|
||||
for (const user of userDetails) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user