mirror of
https://github.com/bitwarden/server.git
synced 2026-06-01 12:26:46 -05:00
ci/github-code-coverage-upload
4 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7180015ed6 |
[PM-37251] Add public invite link GET status endpoint (#7656)
* Implement GetOrganizationInviteLinkStatusQuery to retrieve invite link status - Added GetOrganizationInviteLinkStatusQuery class to handle fetching the status of an organization invite link based on its code. - Introduced OrganizationInviteLinkStatus and OrganizationInviteLinkSsoStatus records to encapsulate the invite link status and SSO information. - Created IGetOrganizationInviteLinkStatusQuery interface to define the contract for the query implementation. * Add unit tests for GetOrganizationInviteLinkStatusQuery - Introduced comprehensive unit tests for GetOrganizationInviteLinkStatusQuery to validate various scenarios including successful retrieval of invite link status, handling of not found errors, and seat availability checks. - Utilized Xunit and NSubstitute for testing and mocking dependencies, ensuring robust coverage of the query's functionality. * Add IGetOrganizationInviteLinkStatusQuery to service collection - Registered IGetOrganizationInviteLinkStatusQuery with the service collection to enable retrieval of organization invite link status. - This addition supports the recently implemented GetOrganizationInviteLinkStatusQuery functionality. * Add OrganizationInviteLinksPublicController and response models - Introduced OrganizationInviteLinksPublicController to handle requests for organization invite link status. - Implemented GetStatus endpoint to retrieve the status of an invite link using its GUID code. - Added OrganizationInviteLinkStatusResponseModel and OrganizationInviteLinkSsoResponseModel to structure the response data for the invite link status. - Ensured the endpoint is accessible to anonymous users while requiring application authorization for other actions. * Add integration tests for OrganizationInviteLinksPublicController - Introduced integration tests for OrganizationInviteLinksPublicController to validate the GetStatus endpoint functionality. - Implemented tests to ensure correct handling of existing invite links and appropriate responses for valid and not found scenarios. - Utilized Xunit and NSubstitute for testing and mocking dependencies, enhancing test coverage for invite link status retrieval. * Updated GetOrganizationInviteLinkStatusQuery to return SSO status based on organization settings, including UseSso and UsePolicies * Move status endpoint into OrganizationInviteLinksController as POST * Refactor OrganizationInviteLinkStatusResponseModel and OrganizationInviteLinkStatus to remove OrganizationId property - Removed OrganizationId property from both OrganizationInviteLinkStatusResponseModel and OrganizationInviteLinkStatus records to streamline the data model. - Updated constructors accordingly to reflect the changes in the response models. * Refactor GetOrganizationInviteLinkStatusQuery to simplify organization checks - Updated the logic in GetOrganizationInviteLinkStatusQuery to streamline organization validation by combining null and enabled checks. - Removed the dependency on IApplicationCacheService and adjusted the seat availability logic to enhance clarity and efficiency. - Modified the return statement to use organization name directly instead of organization ID. * Add integration tests for OrganizationInviteLinksController - Introduced a new test method to validate the GetStatus functionality for existing invite links in OrganizationInviteLinksControllerTests. - Enhanced existing tests to ensure correct responses for valid and not found scenarios. - Removed OrganizationInviteLinksPublicControllerTests as its functionality is now covered in the OrganizationInviteLinksControllerTests. * Refactor OrganizationInviteLinksControllerTests - Updated test methods in OrganizationInviteLinksControllerTests to utilize GetOrganizationInviteLinkStatusRequestModel instead of individual parameters. - Added a new test case to handle scenarios where the invite link status is not available, returning a BadRequest response. - Enhanced existing tests to ensure consistent handling of valid and not found scenarios. * Update GetOrganizationInviteLinkStatusQueryTests to enable organization for invite link tests |
||
|
|
5289a5fd8c |
[PM-34388] Add organization invite link update endpoint (#7560)
* Add InviteLinkDomainSanitizer utility for domain normalization - Introduced InviteLinkDomainSanitizer class to normalize invite link domains by converting them to lowercase and removing blank entries. - The SanitizeDomains method processes a list of domains, ensuring clean and valid entries for further use. * Refactor CreateOrganizationInviteLinkCommand to use InviteLinkDomainSanitizer * Add UpdateOrganizationInviteLinkRequest record for managing invite link updates - Introduced a new record, UpdateOrganizationInviteLinkRequest, to encapsulate the data required for updating organization invite links. - The record includes properties for OrganizationId and AllowedDomains, ensuring structured data handling for invite link modifications. * Add UpdateOrganizationInviteLinkRequestModel for invite link updates - Introduced UpdateOrganizationInviteLinkRequestModel class to facilitate the update of organization invite links. - The model includes a required property for AllowedDomains, ensuring validation and structured data handling for invite link modifications. * Add tests for UpdateOrganizationInviteLinkRequestModel validation * Add unit tests for UpdateOrganizationInviteLinkCommand - Introduced comprehensive tests for the UpdateOrganizationInviteLinkCommand, covering scenarios such as successful updates, handling of non-existing links, and validation of allowed domains. - Ensured that the command behaves correctly under various conditions, including ability checks and input validation. * Add UpdateOrganizationInviteLinkCommand and IUpdateOrganizationInviteLinkCommand interface - Implemented UpdateOrganizationInviteLinkCommand to handle updates for organization invite links, including validation of allowed domains and organization abilities. - Created IUpdateOrganizationInviteLinkCommand interface to define the contract for updating invite links, ensuring structured handling of update requests. * Add IUpdateOrganizationInviteLinkCommand registration to service collection - Registered the IUpdateOrganizationInviteLinkCommand interface with the service collection, enabling dependency injection for the UpdateOrganizationInviteLinkCommand functionality. * Add Update endpoint to OrganizationInviteLinksController - Implemented the Update method in OrganizationInviteLinksController to handle updates for organization invite links. - The method utilizes the IUpdateOrganizationInviteLinkCommand to process update requests and returns the appropriate response model. - Enhanced the controller's functionality to support invite link modifications, ensuring better management of organization invite links. * Add unit tests for Update method in OrganizationInviteLinksController - Implemented multiple test cases for the Update method, covering scenarios such as successful updates, handling of non-existing invite links, and validation errors for allowed domains. - Ensured comprehensive coverage of the Update functionality to validate correct behavior and response models in various conditions. * Add integration test for updating organization invite links * fix(invite-link): add [MinLength(1)] to Update request model and matching test |
||
|
|
5ae857002c |
[PM-34774] Add GET endpoint for organization invite links (#7534)
* Add Get method to OrganizationInviteLinksController for retrieving invite links by organization ID - Implemented a new GET endpoint to fetch an invite link based on the organization ID. - Integrated IOrganizationInviteLinkRepository to handle data retrieval. - Updated tests to validate the new functionality, ensuring correct responses for existing and non-existing links. - Refactored service registration for invite link commands to improve clarity. * Add GetOrganizationInviteLinkQuery and IGetOrganizationInviteLinkQuery interface - Implemented GetOrganizationInviteLinkQuery to retrieve invite links for organizations. - Added IGetOrganizationInviteLinkQuery interface defining the contract for fetching invite links. - Included error handling for cases where invite links are not available or do not exist. * Add unit tests for GetOrganizationInviteLinkQuery - Created GetOrganizationInviteLinkQueryTests to validate the functionality of retrieving organization invite links. - Implemented tests for successful retrieval, handling cases where no link exists, and scenarios with insufficient permissions or null abilities. - Ensured proper error handling and assertions for various outcomes in the query execution. * Add InviteLinkNotFound error type for handling missing invite links - Introduced InviteLinkNotFound record to represent a not found error for invite links. - Enhanced error handling in the InviteLinks feature to provide clearer feedback when an invite link is not found. * Add IGetOrganizationInviteLinkQuery to service collection - Registered IGetOrganizationInviteLinkQuery with the service collection to enable dependency injection for retrieving organization invite links. - This addition supports the functionality introduced in the GetOrganizationInviteLinkQuery implementation. * Refactor OrganizationInviteLinksController to use IGetOrganizationInviteLinkQuery - Updated OrganizationInviteLinksController to replace IOrganizationInviteLinkRepository with IGetOrganizationInviteLinkQuery for retrieving invite links. - Enhanced the Get method to handle results more effectively, returning appropriate responses based on the query outcome. - Modified unit tests to align with the new query implementation, ensuring proper handling of both found and not found scenarios. * Set AllowedDomains for invite link in OrganizationInviteLinksControllerTests |
||
|
|
2a52362d33 |
[PM-34387] Add organization invite link creation endpoint (#7477)
* Add ConflictError type * Add generic Handle<T> and extract MapError on BaseAdminConsoleController * Initialize Code property with a new GUID in OrganizationInviteLink class * Add ICreateOrganizationInviteLinkCommand interface * Add CreateOrganizationInviteLinkRequest record for invite link creation * Add OrganizationInviteLink request and response models for invite link management * Refactor ICreateOrganizationInviteLinkCommand interface to use CreateOrganizationInviteLinkRequest for invite link creation * Add CreateOrganizationInviteLinkCommand class to handle invite link creation logic, including domain sanitization and validation checks. * Add error handling for invite link creation with specific conflict and validation errors * Add OrganizationInviteLink service commands to OrganizationServiceCollectionExtensions * Add OrganizationInviteLinksController to manage invite link creation for organizations * Add integration tests for OrganizationInviteLinksController and CreateOrganizationInviteLinkCommand to validate invite link creation logic, including success and error scenarios. * Remove unnecessary blank line in OrganizationInviteLinksControllerTests class * Refactor CreateOrganizationInviteLinkRequestModel to use required properties for AllowedDomains and EncryptedInviteKey * Update CreateOrganizationInviteLinkCommand to validate allowed domains by using DomainNameValidator * Add encryption validation attributes to CreateOrganizationInviteLinkRequestModel and implement unit tests for model validation * Refactor OrganizationInviteLink to encapsulate AllowedDomains serialization logic within methods. Update OrganizationInviteLinkResponseModel to utilize new GetAllowedDomains method for improved clarity and maintainability. * Enhance domain sanitization in CreateOrganizationInviteLinkCommand by converting domains to lowercase during trimming for improved consistency. * Update OrganizationInviteLinksControllerTests to use a valid encrypted invite key constant for consistency in test cases. * Add ability check for organization invite links in CreateOrganizationInviteLinkCommand - Introduced a new method to verify if an organization can use invite links based on its ability. - Added a new error type for cases where invite links are not available due to organizational plan restrictions. - Updated tests to cover scenarios where the organization lacks the ability to create invite links. * Add documentation for Code property in OrganizationInviteLink class - Added XML summary comments to the Code property to clarify its purpose and generation method. - Explained the choice of using Guid.NewGuid for the Code to avoid predictability and ensure uniqueness. * Implement domain validation in CreateOrganizationInviteLinkRequestModel - Added IValidatableObject implementation to CreateOrganizationInviteLinkRequestModel for domain validation. - Introduced Validate method to check the format of allowed domains and return appropriate validation results. - Updated tests to cover scenarios for invalid domain formats and mixed valid/invalid domains. - Removed redundant domain validation logic from CreateOrganizationInviteLinkCommand. * Remove outdated tests from CreateOrganizationInviteLinkRequestModelTests - Deleted tests for validating EncryptedInviteKey and EncryptedOrgKey as they are no longer relevant. - Cleaned up the test class to focus on current validation logic for allowed domains. * Refactor GetAllowedDomains method in OrganizationInviteLink class - Updated the GetAllowedDomains method to return an empty array instead of throwing a JsonException when deserialization fails. - This change improves the method's resilience by providing a default value for invalid or missing allowed domains. * Remove unused InviteLinkInvalidDomains error type from Errors.cs - Deleted the InviteLinkInvalidDomains record as it is no longer needed. - This cleanup aligns with recent changes in domain validation logic and improves code maintainability. * Update OrganizationServiceCollectionExtensions to use TryAddScoped for command registration - Changed the registration of ICreateOrganizationInviteLinkCommand to use TryAddScoped instead of AddScoped. * Mock organization ability retrieval in OrganizationInviteLinksControllerTests * Add ValidateSequenceAttribute for collection validation and corresponding unit tests * Refactor CreateOrganizationInviteLinkRequestModel to use ValidateSequenceAttribute for domain validation and update unit tests for improved error handling. * Enhance ValidateSequenceAttribute to handle null values and improve error messaging format * Add empty line * Refactor ValidateSequenceAttribute to support IEnumerable interface for improved type handling * Refactor ValidateSequenceAttribute to improve validation logic and error handling for IEnumerable types * Remove unused using directive for Microsoft.AspNetCore.Http.HttpResults in BaseAdminConsoleController.cs * Add MinLength validation to AllowedDomains in CreateOrganizationInviteLinkRequestModel and implement unit test for empty AllowedDomains scenario * Refactor CreateOrganizationInviteLinkCommandTests to move SetupAbility method for better organization and readability * Add error handling methods in BaseAdminConsoleController for improved response management * Update CreateOrganizationInviteLinkRequestModelTests to use array initialization syntax for AllowedDomains so that MinLength attribute works * Refactor OrganizationInviteLinkResponseModel constructor for improved readability |