mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-21 16:18:28 +01:00
remove logic for personal ownership, not needed in AC
This commit is contained in:
parent
caa3b46f50
commit
f04fef59f4
@ -4,7 +4,6 @@ import { BehaviorSubject } from "rxjs";
|
||||
import { CollectionAdminService } from "@bitwarden/admin-console/common";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { CipherId } from "@bitwarden/common/types/guid";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
@ -18,7 +17,6 @@ describe("AdminConsoleCipherFormConfigService", () => {
|
||||
|
||||
const cipherId = "333-444-555" as CipherId;
|
||||
const testOrg = { id: "333-44-55", name: "Test Org", canEditAllCiphers: false };
|
||||
const policyAppliesToActiveUser$ = new BehaviorSubject<boolean>(true);
|
||||
const organization$ = new BehaviorSubject<Organization>(testOrg as Organization);
|
||||
const getCipherAdmin = jest.fn().mockResolvedValue(null);
|
||||
const getCipher = jest.fn().mockResolvedValue(null);
|
||||
@ -32,10 +30,6 @@ describe("AdminConsoleCipherFormConfigService", () => {
|
||||
await TestBed.configureTestingModule({
|
||||
providers: [
|
||||
AdminConsoleCipherFormConfigService,
|
||||
{
|
||||
provide: PolicyService,
|
||||
useValue: { policyAppliesToActiveUser$: () => policyAppliesToActiveUser$ },
|
||||
},
|
||||
{ provide: OrganizationService, useValue: { get$: () => organization$ } },
|
||||
{ provide: CipherService, useValue: { get: getCipher } },
|
||||
{ provide: CollectionAdminService, useValue: { getAll: () => Promise.resolve([]) } },
|
||||
@ -85,20 +79,12 @@ describe("AdminConsoleCipherFormConfigService", () => {
|
||||
expect(result.admin).toBe(true);
|
||||
});
|
||||
|
||||
it("sets `allowPersonalOwnership`", async () => {
|
||||
it("sets `allowPersonalOwnership` to false", async () => {
|
||||
adminConsoleConfigService = TestBed.inject(AdminConsoleCipherFormConfigService);
|
||||
|
||||
policyAppliesToActiveUser$.next(true);
|
||||
|
||||
let result = await adminConsoleConfigService.buildConfig("clone", cipherId);
|
||||
const result = await adminConsoleConfigService.buildConfig("clone", cipherId);
|
||||
|
||||
expect(result.allowPersonalOwnership).toBe(false);
|
||||
|
||||
policyAppliesToActiveUser$.next(false);
|
||||
|
||||
result = await adminConsoleConfigService.buildConfig("clone", cipherId);
|
||||
|
||||
expect(result.allowPersonalOwnership).toBe(true);
|
||||
});
|
||||
|
||||
describe("getCipher", () => {
|
||||
|
@ -4,8 +4,6 @@ import { combineLatest, filter, firstValueFrom, map, switchMap } from "rxjs";
|
||||
import { CollectionAdminService } from "@bitwarden/admin-console/common";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { CipherId } from "@bitwarden/common/types/guid";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
@ -23,17 +21,12 @@ import { RoutedVaultFilterService } from "../../individual-vault/vault-filter/se
|
||||
/** Admin Console implementation of the `CipherFormConfigService`. */
|
||||
@Injectable()
|
||||
export class AdminConsoleCipherFormConfigService implements CipherFormConfigService {
|
||||
private policyService: PolicyService = inject(PolicyService);
|
||||
private organizationService: OrganizationService = inject(OrganizationService);
|
||||
private cipherService: CipherService = inject(CipherService);
|
||||
private routedVaultFilterService: RoutedVaultFilterService = inject(RoutedVaultFilterService);
|
||||
private collectionAdminService: CollectionAdminService = inject(CollectionAdminService);
|
||||
private apiService: ApiService = inject(ApiService);
|
||||
|
||||
private allowPersonalOwnership$ = this.policyService
|
||||
.policyAppliesToActiveUser$(PolicyType.PersonalOwnership)
|
||||
.pipe(map((p) => !p));
|
||||
|
||||
private organizationId$ = this.routedVaultFilterService.filter$.pipe(
|
||||
map((filter) => filter.organizationId),
|
||||
filter((filter) => filter !== undefined),
|
||||
@ -60,8 +53,8 @@ export class AdminConsoleCipherFormConfigService implements CipherFormConfigServ
|
||||
cipherId?: CipherId,
|
||||
cipherType?: CipherType,
|
||||
): Promise<CipherFormConfig> {
|
||||
const [organization, allowPersonalOwnership, allCollections] = await firstValueFrom(
|
||||
combineLatest([this.organization$, this.allowPersonalOwnership$, this.editableCollections$]),
|
||||
const [organization, allCollections] = await firstValueFrom(
|
||||
combineLatest([this.organization$, this.editableCollections$]),
|
||||
);
|
||||
|
||||
const cipher = await this.getCipher(organization, cipherId);
|
||||
@ -74,7 +67,7 @@ export class AdminConsoleCipherFormConfigService implements CipherFormConfigServ
|
||||
mode,
|
||||
cipherType: cipher?.type ?? cipherType ?? CipherType.Login,
|
||||
admin: organization.canEditAllCiphers ?? false,
|
||||
allowPersonalOwnership,
|
||||
allowPersonalOwnership: false,
|
||||
originalCipher: cipher,
|
||||
collections,
|
||||
organizations: [organization], // only a single org is in context at a time
|
||||
|
Loading…
Reference in New Issue
Block a user