@@ -1790,118 +1790,6 @@ await Assert.ThrowsAsync<NotFoundException>(
17901790 ) ;
17911791 }
17921792
1793- [ Theory , BitAutoData ]
1794- public async Task PutShareMany_ArchivedCipher_ThrowsBadRequestException (
1795- Guid organizationId ,
1796- Guid userId ,
1797- CipherWithIdRequestModel request ,
1798- SutProvider < CiphersController > sutProvider )
1799- {
1800- request . EncryptedFor = userId ;
1801- request . OrganizationId = organizationId . ToString ( ) ;
1802- request . ArchivedDate = DateTime . UtcNow ;
1803- var model = new CipherBulkShareRequestModel
1804- {
1805- Ciphers = [ request ] ,
1806- CollectionIds = [ Guid . NewGuid ( ) . ToString ( ) ]
1807- } ;
1808-
1809- sutProvider . GetDependency < ICurrentContext > ( )
1810- . OrganizationUser ( organizationId )
1811- . Returns ( Task . FromResult ( true ) ) ;
1812- sutProvider . GetDependency < IUserService > ( )
1813- . GetProperUserId ( default )
1814- . ReturnsForAnyArgs ( userId ) ;
1815-
1816- var exception = await Assert . ThrowsAsync < BadRequestException > (
1817- ( ) => sutProvider . Sut . PutShareMany ( model )
1818- ) ;
1819-
1820- Assert . Equal ( "Cannot move archived items to an organization." , exception . Message ) ;
1821- }
1822-
1823- [ Theory , BitAutoData ]
1824- public async Task PutShareMany_ExistingCipherArchived_ThrowsBadRequestException (
1825- Guid organizationId ,
1826- Guid userId ,
1827- CipherWithIdRequestModel request ,
1828- SutProvider < CiphersController > sutProvider )
1829- {
1830- // Request model does not have ArchivedDate (only the existing cipher does)
1831- request . EncryptedFor = userId ;
1832- request . OrganizationId = organizationId . ToString ( ) ;
1833- request . ArchivedDate = null ;
1834-
1835- var model = new CipherBulkShareRequestModel
1836- {
1837- Ciphers = [ request ] ,
1838- CollectionIds = [ Guid . NewGuid ( ) . ToString ( ) ]
1839- } ;
1840-
1841- // The existing cipher from the repository IS archived
1842- var existingCipher = new CipherDetails
1843- {
1844- Id = request . Id ! . Value ,
1845- UserId = userId ,
1846- Type = CipherType . Login ,
1847- Data = JsonSerializer . Serialize ( new CipherLoginData ( ) ) ,
1848- ArchivedDate = DateTime . UtcNow
1849- } ;
1850-
1851- sutProvider . GetDependency < ICurrentContext > ( )
1852- . OrganizationUser ( organizationId )
1853- . Returns ( Task . FromResult ( true ) ) ;
1854- sutProvider . GetDependency < IUserService > ( )
1855- . GetProperUserId ( default )
1856- . ReturnsForAnyArgs ( userId ) ;
1857- sutProvider . GetDependency < ICipherRepository > ( )
1858- . GetManyByUserIdAsync ( userId , withOrganizations : false )
1859- . Returns ( Task . FromResult ( ( ICollection < CipherDetails > ) [ existingCipher ] ) ) ;
1860-
1861- var exception = await Assert . ThrowsAsync < BadRequestException > (
1862- ( ) => sutProvider . Sut . PutShareMany ( model )
1863- ) ;
1864-
1865- Assert . Equal ( "Cannot move archived items to an organization." , exception . Message ) ;
1866- }
1867-
1868- [ Theory , BitAutoData ]
1869- public async Task PutShare_ArchivedCipher_ThrowsBadRequestException (
1870- Guid cipherId ,
1871- Guid organizationId ,
1872- User user ,
1873- CipherShareRequestModel model ,
1874- SutProvider < CiphersController > sutProvider )
1875- {
1876- model . Cipher . OrganizationId = organizationId . ToString ( ) ;
1877- model . Cipher . EncryptedFor = user . Id ;
1878-
1879- var cipher = new Cipher
1880- {
1881- Id = cipherId ,
1882- UserId = user . Id ,
1883- ArchivedDate = DateTime . UtcNow . AddDays ( - 1 ) ,
1884- Type = CipherType . Login ,
1885- Data = JsonSerializer . Serialize ( new CipherLoginData ( ) )
1886- } ;
1887-
1888- sutProvider . GetDependency < IUserService > ( )
1889- . GetUserByPrincipalAsync ( Arg . Any < ClaimsPrincipal > ( ) )
1890- . Returns ( user ) ;
1891- sutProvider . GetDependency < ICipherRepository > ( )
1892- . GetByIdAsync ( cipherId )
1893- . Returns ( cipher ) ;
1894- sutProvider . GetDependency < ICurrentContext > ( )
1895- . OrganizationUser ( organizationId )
1896- . Returns ( Task . FromResult ( true ) ) ;
1897-
1898- var exception = await Assert . ThrowsAsync < BadRequestException > (
1899- ( ) => sutProvider . Sut . PutShare ( cipherId , model )
1900- ) ;
1901-
1902- Assert . Equal ( "Cannot move an archived item to an organization." , exception . Message ) ;
1903- }
1904-
19051793 [ Theory , BitAutoData ]
19061794 public async Task PostPurge_WhenUserNotFound_ThrowsUnauthorizedAccessException (
19071795 SecretVerificationRequestModel model ,
0 commit comments