Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(default_group): exposed deafult_group in /users/self #2209

Merged
merged 1 commit into from
May 24, 2022

Conversation

pret3nti0u5
Copy link
Contributor

@pret3nti0u5 pret3nti0u5 commented Apr 8, 2022

Description

Exposed default_group in endpoint /api/v1/users/self. Closes #2208. This in regards to the discussion I and @GMishx had on thread #199.

Changes

Edited UserController.php for exposing key and openapi.yaml for updating documentation.

How to test

Send GET request to endpoint /api/v1/users/self

Closes #2208
Closes #2054

@pret3nti0u5
Copy link
Contributor Author

I am not sure how to write tests for the changed function, so if anyone can suggest the required changes that would be great.

@GMishx
Copy link
Member

GMishx commented May 5, 2022

I am not sure how to write tests for the changed function, so if anyone can suggest the required changes that would be great.

Hey @pret3nti0u5 ,

You need to modify

public function testGetCurrentUser()

You need to create an object of UserDao in setUp() as done in

$this->restHelper->shouldReceive('getUserDao')
->andReturn($this->userDao);

And then add following lines to function before creating $actualResponse variable.

$user[0]["default_group"] = "fossy";
$this->userDao->shouldReceive('getUserAndDefaultGroupByUserName')->withArgs([$user[0]["name"])
      ->andReturn(["group_name" => "fossy"]);

@pret3nti0u5
Copy link
Contributor Author

@GMishx Guess this should work. Let me know if any changes are required.

Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

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

Changes looks good.

@GMishx
Copy link
Member

GMishx commented May 12, 2022

@pret3nti0u5 can you please squash the commits?

Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

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

Tested, working as expected.

@GMishx GMishx added ready and removed needs test labels May 12, 2022
fix(default_group): Removed whitespace to fix codesniffer warning

fix(default_group): Added tests for UserController.php
@pret3nti0u5
Copy link
Contributor Author

@pret3nti0u5 can you please squash the commits?

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

default_group not exposed in response api/v1/users/self endpoint. REST API: default group on login
3 participants