* Add support for bulk confirm
* Add missing sproc to migration
* Change ConfirmUserAsync to internally use ConfirmUsersAsync
* Refactor to be a bit more readable
* Change BulkReinvite and BulkRemove to return a list of errors/success
* Refactor
* Fix removing owner preventing removing non owners
* Add another unit test
* Use fixtures for OrganizationUser and Policies
* Fix spelling
* Increase organization max seat size from 30k to 2b (#1274)
* Increase organization max seat size from 30k to 2b
* PR review. Do not modify unless state matches expected
* Organization sync simultaneous event reporting (#1275)
* Split up azure messages according to max size
* Allow simultaneous login of organization user events
* Early resolve small event lists
* Clarify logic
Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
* Improve readability
This comes at the cost of multiple serializations, but the
improvement in wire-time should more than make up for this
on message where serialization time matters
Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
* Queue emails (#1286)
* Extract common Azure queue methods
* Do not use internal entity framework namespace
* Prefer IEnumerable to IList unless needed
All of these implementations were just using `Count == 1`,
which is easily replicated. This will be used when abstracting Azure queues
* Add model for azure queue message
* Abstract Azure queue for reuse
* Creat service to enqueue mail messages for later processing
Azure queue mail service uses Azure queues.
Blocking just blocks until all the work is done -- This is
how emailing works today
* Provide mail queue service to DI
* Queue organization invite emails for later processing
All emails can later be added to this queue
* Create Admin hosted service to process enqueued mail messages
* Prefer constructors to static generators
* Mass delete organization users (#1287)
* Add delete many to Organization Users
* Correct formatting
* Remove erroneous migration
* Clarify parameter name
* Formatting fixes
* Simplify bump account revision sproc
* Formatting fixes
* Match file names to objects
* Indicate if large import is expected
* Early pull all existing users we were planning on inviting (#1290)
* Early pull all existing users we were planning on inviting
* Improve sproc name
* Batch upsert org users (#1289)
* Add UpsertMany sprocs to OrganizationUser
* Add method to create TVPs from any object.
Uses DbOrder attribute to generate.
Sproc will fail unless TVP column order matches that of the db type
* Combine migrations
* Correct formatting
* Include sql objects in sql project
* Keep consisten parameter names
* Batch deletes for performance
* Correct formatting
* consolidate migrations
* Use batch methods in OrganizationImport
* Declare @BatchSize
* Transaction names limited to 32 chars
Drop sproc before creating it if it exists
* Update import tests
* Allow for more users in org upgrades
* Fix formatting
* Improve class hierarchy structure
* Use name tuple types
* Fix formatting
* Front load all reflection
* Format constructor
* Simplify ToTvp as class-specific extension
Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
* Add API for bulk removal of org users
* Refactor OrganizationService, extract some common code.
* Add tests for DeleteUserAsync
* Add tests for DeleteUsers
* Formating
* Update test/Core.Test/Services/OrganizationServiceTests.cs
added a space
Co-authored-by: Addison Beck <abeck@bitwarden.com>
* Add send HideEmail to tables and models
* Respect HideEmail setting for Sends
* Recreate SendView to include new HideEmail column
* Enforce new Send policy
* Insert default value for new HideEmail column
* Delete c95d7598-71cc-4eab-8b08-aced0045198b.json
* Remove unrelated files
* Revert disableSendPolicy, add sendOptionsPolicy
* Minor style fixes
* Update SQL project with Send.HideEmail column
* unit test SendOptionsPolicy.DisableHideEmail
* Add SendOptionsPolicy to Portal
* Make HideEmail nullable, fix migrator script
* Remove NOT NULL constraint from HideEmail
* Fix style
* Make HideEmail nullable
* minor fixes to model and error message
* Move SendOptionsExemption banner
Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
* Get limited life attachment download URL
This change limits url download to a 1min lifetime.
This requires moving to a new container to allow for non-public blob
access.
Clients will have to call GetAttachmentData api function to receive the download
URL. For backwards compatibility, attachment URLs are still present, but will not
work for attachments stored in non-public access blobs.
* Make GlobalSettings interface for testing
* Test LocalAttachmentStorageService equivalence
* Remove comment
* Add missing globalSettings using
* Simplify default attachment container
* Default to attachments containe for existing methods
A new upload method will be made for uploading to attachments-v2.
For compatibility for clients which don't use these new methods, we need
to still use the old container. The new container will be used only for
new uploads
* Remove Default MetaData fixture.
* Keep attachments container blob-level security for all instances
* Close unclosed FileStream
* Favor default value for noop services
* Add Disable Send policy
* Test DisableSend policy
* PR Review
* Update tests for using CurrentContext
This required making an interface for CurrentContext and mocking out
the members used. The interface can be expanded as needed for tests.
I moved CurrentContext to a folder, which changes the namespace
and causes a lot of file touches, but most are just adding a reference
* Fix failing test
* Update exemption to include all exempt users
* Move all CurrentContext usages to ICurrentContext
* PR review. Match messaging with Web
* Null checked org invite collections
* Null checked permissions on org invite
* Gave a static seat count to org invite fixture
* Null checked the right way
* Implemented Custom role and permissions
* Converted permissions columns to a json blob
* Code review fixes for Permissions
* sql build fix
* Update Permissions.cs
* formatting
* Update IOrganizationService.cs
* reworked a conditional
* built out tests for relevant organization service methods
* removed unused usings
* fixed a broken test and a bad empty string init
* removed 'Attribute' from some attribute instances
* Return revised ciphers on restore api call
* Return restored date from restore sproc
* Test Restore updates passed in ciphers
This is necessary for CipherController to appropriately return the
up-to-date ciphers without an extra db call to read them.
* Add missing SELECT
* Add last updated validation to cipher replacements
* Add AutoFixture scaffolding.
AutoDataAttributes and ICustomizations are meant to automatically
produce valid test input. Examples are the Cipher customizations,
which enforce the model's mutual exclusivity of UserId and
OrganizationId.
FixtureExtensions create a fluent way to generate SUTs. We currently
use parameter injection to fascilitate service testing, which is nicely
handled by AutoNSubstitute. However, in order to gain access to the
substitutions, we need to Freeze them onto the Fixture. The For fluent
method allows specifying a Freeze to a specific type's constructor and
optionally to a parameter name in that constructor.
* Unit tests for single Cipher update version checks
* Fix test runner
Test runner requires Microsoft.NET.Test.Sdk
* Move to provider model for SUT generation
This model differs from previous in that you no longer need to specify
which dependencies you would like access to. Instead, all are
remembered and can be queried through the sutProvider.
* User cipher provided by Put method reads
Every put method already reads all relevant ciphers from database,
there's no need to re-read them.
JSON serialization of datetimes seems to leave truncate at second
precision. Verify last known date time is within one second rather than
exact.
* validate revision date for share many requests
* Update build script to use Github environment path
Co-authored-by: Matt Gibson <mdgibson@Matts-MBP.lan>
* Initial commit of accept user during set password flow
* changed new org user from accepted to invited // moved another check to token accept function
* Revised some white space // Moved business logic to UserService
* Fixed UserServiceTest
* Removed some white-space
* Removed more white-space
* Final white-space issues
* facilitate linking/unlinking existing users from an sso enabled org
* added user_identifier to identity methods for sso
* moved sso user delete method to account controller
* fixed a broken test
* Update AccountsController.cs
* facilitate linking/unlinking existing users from an sso enabled org
* added user_identifier to identity methods for sso
* moved sso user delete method to account controller
* fixed a broken test
* added a token to the existing user sso link flow
* added a token to the existing user sso link flow
* fixed a typo
* added an event log for unlink ssoUser records
* fixed a merge issue
* fixed a busted test
* fixed a busted test
* ran a formatter over everything & changed .vscode settings in .gitignore
* chagned a variable to use string interpolation
* removed a blank line
* Changed TokenPurpose enum to a static class of strings
* code review cleanups
* formatting fix
* Changed parameters & logging for delete sso user
* changed th method used to get organization user for deleting sso user records
Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
Following the paradigms illustrated in "Working Effectively with Legacy
Code", this commit introduces at least one test for each service class
implementation. This test is a simple construction test -- we just
create each service and assert that it exists. Each test suite includes
a comment instructing the developer who comes next to remove the
constructor test. We don't want to keep these tests as the codebase
matures, as they aren't useful in the longterm. They only prove that we
have that class under test.
Where test suites failed to construct their associated classes, we skip
the test but leave behind the implementation. This is by design, so that
as the constructors for those classes change, we are forced to keep the
test suite current by leaning on the compiler.