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

RBAC - REST APIs #2773

Merged
merged 44 commits into from
Jul 19, 2024
Merged

RBAC - REST APIs #2773

merged 44 commits into from
Jul 19, 2024

Conversation

TLeoDev
Copy link
Member

@TLeoDev TLeoDev commented Jan 8, 2024

Description

What's new?

  • Creation of GetAll and GetDetails api for Group, User, AccessControl and Role classes.

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

@TLeoDev TLeoDev requested a review from a team as a code owner January 8, 2024 16:16
@TLeoDev TLeoDev self-assigned this Jan 8, 2024
@TLeoDev TLeoDev changed the title Role based access control ap is Role based access control apis Jan 8, 2024
src/IoTHub.Portal.Shared/Models/v1.0/RoleDetailsModel.cs Outdated Show resolved Hide resolved
src/IoTHub.Portal.Shared/Models/v1.0/ActionModel.cs Outdated Show resolved Hide resolved
src/IoTHub.Portal.Shared/Models/v1.0/UserDetailsModel.cs Outdated Show resolved Hide resolved
src/IoTHub.Portal.Shared/Models/v1.0/UserModel.cs Outdated Show resolved Hide resolved
src/IoTHub.Portal.Shared/Models/v1.0/GroupModel.cs Outdated Show resolved Hide resolved
src/IoTHub.Portal.Shared/Models/v1.0/UserModel.cs Outdated Show resolved Hide resolved
@kbeaugrand kbeaugrand self-requested a review January 15, 2024 14:35
@kbeaugrand kbeaugrand marked this pull request as draft January 18, 2024 12:28
@TLeoDev TLeoDev marked this pull request as ready for review May 13, 2024 07:17
@TLeoDev TLeoDev requested a review from kbeaugrand May 17, 2024 06:41
@Metal-Mighty Metal-Mighty changed the title Role based access control apis RBAC - REST APIs May 24, 2024
Copy link

@Metal-Mighty Metal-Mighty left a comment

Choose a reason for hiding this comment

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

Additionally to requested changes on specific files, please also extend all your unit tests to cover situations where the tested feature doesn't work and returns an error, in order to make sure we handle errors properly, with the correct errors and error codes, etc

src/IoTHub.Portal.Domain/Entities/indexerAttribute.cs Outdated Show resolved Hide resolved
var existingName = await this.groupRepository.GetByNameAsync(group.Name);
if (existingName is not null)
{
throw new ResourceAlreadyExistsException($"The Group tis the name {group.Name} already exist !");

Choose a reason for hiding this comment

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

Error typo

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

var existingName = await this.userRepository.GetByNameAsync(user.Name);
if (existingName is not null)
{
throw new ResourceAlreadyExistsException($"The User tis the name {user.Name} already exist !");

Choose a reason for hiding this comment

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

Error typo

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

var user = await userRepository.GetByIdAsync(id);
if (user is null)
{
throw new ResourceNotFoundException($"The User with the id {id} that you want to delete does'nt exist !");

Choose a reason for hiding this comment

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

Error typo

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

}

/*[Test]
public async Task DeleteAccessControlShouldReturnExpectedBehavior()

Choose a reason for hiding this comment

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

Would be better if this test was uncommented and working :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I made the changes, its working now

return Ok(await groupManagementService.DeleteGroup(id));
try
{
var result =await groupManagementService.DeleteGroup(id);
Copy link
Member Author

Choose a reason for hiding this comment

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

The code in the try is never reached

Copy link
Member Author

Choose a reason for hiding this comment

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

I made the changes

Copy link

@Metal-Mighty Metal-Mighty left a comment

Choose a reason for hiding this comment

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

Use AutoFixtures in all Unit Tests, some are missing
Add tests of limits in methods

@@ -130,7 +130,7 @@ private static IServiceCollection ConfigureImageBlobStorage(this IServiceCollect
var serviceClient = new BlobServiceClient(configuration.AzureStorageAccountConnectionString);
var container = serviceClient.GetBlobContainerClient(opts.ImageContainerName);

_ = container.SetAccessPolicy(PublicAccessType.Blob);

Choose a reason for hiding this comment

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

This shouldn't be commented in production code since it only impacts us on our test infrastructure (and will be handled in #3076)

@TLeoDev TLeoDev merged commit 1d9ee76 into RoleBasedAccessControl Jul 19, 2024
@TLeoDev TLeoDev deleted the RoleBasedAccessControl-APIs branch July 19, 2024 14:15
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.

None yet

3 participants