Skip to content

Commit

Permalink
[ENG-1037] - added /group/type/:type/user/:id/:property
Browse files Browse the repository at this point in the history
  • Loading branch information
Phara0h committed Oct 14, 2019
1 parent d36cef2 commit f4ba5fe
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 5 deletions.
141 changes: 140 additions & 1 deletion postman/Travelling.postman_collection.json
Expand Up @@ -369,7 +369,7 @@
}
]
},
"description": "Resets the password if the recovery token is valid of the user."
"description": "Resets the password if the recovery token is vaild of the user."
},
"response": []
},
Expand Down Expand Up @@ -1007,6 +1007,121 @@
}
]
},
{
"name": "Get Property",
"request": {
"method": "GET",
"header": [
{
"description": "The client_credentials generated OAUth2 access token.",
"key": "Authorization",
"type": "text",
"value": "Bearer"
}
],
"url": {
"raw": "{{TRAV}}/travelling/api/v1/group/type/:type/user/:id/:property",
"host": [
"{{TRAV}}"
],
"path": [
"travelling",
"api",
"v1",
"group",
"type",
":type",
"user",
":id",
":property"
],
"variable": [
{
"key": "type",
"value": "accounts"
},
{
"key": "id",
"value": "user6"
},
{
"key": "property",
"value": "email"
}
]
},
"description": "Get a user's property by it's id or username from group of a particular type."
},
"response": [
{
"name": "Get User",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "The client_credentials generated OAUth2 access token.",
"key": "Authorization",
"type": "text",
"value": "Bearer"
}
],
"url": {
"raw": "{{TRAV}}/travelling/api/v1/group/type/:type/user/:id",
"host": [
"{{TRAV}}"
],
"path": [
"travelling",
"api",
"v1",
"group",
"type",
":type",
"user",
":id"
],
"variable": [
{
"key": "type",
"value": "accounts"
},
{
"key": "id",
"value": "user6"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "content-type",
"value": "application/json; charset=utf-8"
},
{
"key": "set-cookie",
"value": "trav:ssid=8b65a9a7-3dc2-4690-9d1b-6b2d5ce56e77%3AcFbTWvWMtztGLpLvm06t7Q%3D%3D.hqi8Fw1aUqhKts6T1b%2BlAiHj1kmkEhLJYw7WK9BpcNY; Max-Age=10000; Path=/; Expires=Mon, 16 Sep 2019 15:57:33 GMT; HttpOnly"
},
{
"key": "content-length",
"value": "692"
},
{
"key": "Date",
"value": "Mon, 16 Sep 2019 15:57:23 GMT"
},
{
"key": "Connection",
"value": "keep-alive"
}
],
"cookie": [],
"body": "{\n \"id\": \"bda05e2c-a8de-464e-949c-656e527c374c\",\n \"username\": \"user6\",\n \"password\": \"17c24abfa17fda309c844062bc23b1cbf7af96cc0bd1c399800fc23be18a86f8\",\n \"avatar\": null,\n \"locked\": true,\n \"locked_reason\": \"Activation Required, email your admin to get your account activated\",\n \"group_request\": \"superadmin\",\n \"failed_login_attempts\": 0,\n \"change_username\": false,\n \"change_password\": false,\n \"reset_password\": false,\n \"email_verify\": false,\n \"group_id\": \"6b88967a-1b9e-41ae-8140-9cc3969c3345\",\n \"email\": \"jt6@abe.ai\",\n \"created_on\": \"1568648238097\",\n \"last_login\": null,\n \"user_data\": null,\n \"eprofile\": null,\n \"group\": {\n \"id\": \"6b88967a-1b9e-41ae-8140-9cc3969c3345\",\n \"name\": \"group9\",\n \"type\": \"accounts\",\n \"allowed\": null,\n \"inherited\": null,\n \"is_default\": true\n }\n}"
}
]
},
{
"name": "Edit",
"request": {
Expand Down Expand Up @@ -1587,6 +1702,30 @@
]
}
],
"description": "Both requests are disabled. Dont use.",
"event": [
{
"listen": "prerequest",
"script": {
"id": "1c5ab9b5-089e-45bd-94b2-7e8370d546c1",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "6f3943c7-595a-440d-8e31-69e027e76f48",
"type": "text/javascript",
"exec": [
""
]
}
}
],
"protocolProfileBehavior": {},
"_postman_isSubFolder": true
},
{
Expand Down
28 changes: 26 additions & 2 deletions sdk/index.js
Expand Up @@ -1276,7 +1276,7 @@ class GroupType {
}
}
/**
*
* Both requests are disabled. Dont use.
*/
class TypeUsers {
constructor() {}
Expand Down Expand Up @@ -1454,6 +1454,30 @@ class TypeUser {
}


/**
* getProperty - Get a user's property by it's id or username from group of a particular type.
* @param {any} type (example: accounts)
* @param {any} id (example: user6)
* @param {any} property (example: email)
* @param {string} authorization_bearer The client_credentials generated OAUth2 access token.
*/
static async getProperty(type, id, property, authorization_bearer, opts) {
var options = {
method: 'GET',
resolveWithFullResponse: true,
simple: false,
uri: hostUrl + "/" + `travelling/api/v1/group/type/${type}/user/${id}/${property}`,
authorization: {
bearer: authorization_bearer
},
};
if (opts) {
options = Object.assign(options, opts);
}
return await fasq.request(options)
}


/**
* get - Get a user by it's id or username from group of a particular type.
* @param {any} type (example: accounts)
Expand Down Expand Up @@ -1613,7 +1637,7 @@ class Auth {


/**
* resetPassword - Resets the password if the recovery token is valid of the user.
* resetPassword - Resets the password if the recovery token is vaild of the user.
* @param {Object} body
* @param {any} token (example: [thegeneratedtoken])
* @example
Expand Down
25 changes: 23 additions & 2 deletions tests/endpoints/user-get.js
Expand Up @@ -160,6 +160,18 @@ module.exports = () => {

expect(res.body).toEqual(userContainer.user2.email);
});


test("Get Test2's Email By Username By Grouptype ", async () => {
var res = await Travelling.Group.Type.User.getProperty('group', userContainer.user2.username, 'email',null, {
headers: {
cookie: userContainer.user2Cookie(),
},
});

expect(res.body).toEqual(userContainer.user2.email);
});

});

describe('Invalid', () => {
Expand All @@ -180,8 +192,6 @@ module.exports = () => {
},
});

console.log(res.body)

expect(res.statusCode).toEqual(400);
});

Expand All @@ -205,6 +215,17 @@ module.exports = () => {
expect(res.statusCode).toEqual(400);
});

test("Get Test2's Email By Username By Invaild Grouptype ", async () => {
var res = await Travelling.Group.Type.User.getProperty('testgroup', userContainer.user2.username, 'email',null, {
headers: {
cookie: userContainer.user2Cookie(),
},
});

expect(res.statusCode).toEqual(400);
expect(res.body).not.toEqual(userContainer.user2.email);
});

})
});

Expand Down

0 comments on commit f4ba5fe

Please sign in to comment.