chore: fix getting vault method (#2547)

* chore: fix getting vault method

* remove only attribute

* fix checking for vaults

* fix expected missing vaults
This commit is contained in:
Karol Sójko
2023-09-28 14:18:48 +02:00
committed by GitHub
parent 397d33285c
commit 4b1140d8f0
13 changed files with 60 additions and 60 deletions

View File

@@ -85,22 +85,8 @@ export class VaultService
return this._getVaults.execute().getValue()
}
public getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): VaultListingInterface | undefined {
const result = this._getVault.execute(dto)
if (result.isFailed()) {
return undefined
}
return result.getValue()
}
public getSureVault(dto: { keySystemIdentifier: KeySystemIdentifier }): VaultListingInterface {
const vault = this.getVault(dto)
if (!vault) {
throw new Error('Vault not found')
}
return vault
getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): Result<VaultListingInterface> {
return this._getVault.execute(dto)
}
async createRandomizedVault(dto: {
@@ -293,7 +279,12 @@ export class VaultService
return undefined
}
return this.getVault({ keySystemIdentifier: latestItem.key_system_identifier })
const vault = this.getVault({ keySystemIdentifier: latestItem.key_system_identifier })
if (vault.isFailed()) {
throw new Error('Cannot find vault for item')
}
return vault.getValue()
}
async changeVaultKeyOptions(dto: ChangeVaultKeyOptionsDTO): Promise<Result<void>> {

View File

@@ -28,7 +28,7 @@ export interface VaultServiceInterface
}): Promise<VaultListingInterface>
getVaults(): VaultListingInterface[]
getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): VaultListingInterface | undefined
getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): Result<VaultListingInterface>
authorizeVaultDeletion(vault: VaultListingInterface): Promise<Result<boolean>>
deleteVault(vault: VaultListingInterface): Promise<boolean>