1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 22:03:36 +00:00

remove logic for personal ownership, not needed in AC

This commit is contained in:
Nick Krantz
2024-10-04 13:14:58 -05:00
parent caa3b46f50
commit f04fef59f4
2 changed files with 5 additions and 26 deletions

View File

@@ -4,7 +4,6 @@ import { BehaviorSubject } from "rxjs";
import { CollectionAdminService } from "@bitwarden/admin-console/common"; import { CollectionAdminService } from "@bitwarden/admin-console/common";
import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; 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 { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { CipherId } from "@bitwarden/common/types/guid"; import { CipherId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
@@ -18,7 +17,6 @@ describe("AdminConsoleCipherFormConfigService", () => {
const cipherId = "333-444-555" as CipherId; const cipherId = "333-444-555" as CipherId;
const testOrg = { id: "333-44-55", name: "Test Org", canEditAllCiphers: false }; 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 organization$ = new BehaviorSubject<Organization>(testOrg as Organization);
const getCipherAdmin = jest.fn().mockResolvedValue(null); const getCipherAdmin = jest.fn().mockResolvedValue(null);
const getCipher = jest.fn().mockResolvedValue(null); const getCipher = jest.fn().mockResolvedValue(null);
@@ -32,10 +30,6 @@ describe("AdminConsoleCipherFormConfigService", () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
providers: [ providers: [
AdminConsoleCipherFormConfigService, AdminConsoleCipherFormConfigService,
{
provide: PolicyService,
useValue: { policyAppliesToActiveUser$: () => policyAppliesToActiveUser$ },
},
{ provide: OrganizationService, useValue: { get$: () => organization$ } }, { provide: OrganizationService, useValue: { get$: () => organization$ } },
{ provide: CipherService, useValue: { get: getCipher } }, { provide: CipherService, useValue: { get: getCipher } },
{ provide: CollectionAdminService, useValue: { getAll: () => Promise.resolve([]) } }, { provide: CollectionAdminService, useValue: { getAll: () => Promise.resolve([]) } },
@@ -85,20 +79,12 @@ describe("AdminConsoleCipherFormConfigService", () => {
expect(result.admin).toBe(true); expect(result.admin).toBe(true);
}); });
it("sets `allowPersonalOwnership`", async () => { it("sets `allowPersonalOwnership` to false", async () => {
adminConsoleConfigService = TestBed.inject(AdminConsoleCipherFormConfigService); adminConsoleConfigService = TestBed.inject(AdminConsoleCipherFormConfigService);
policyAppliesToActiveUser$.next(true); const result = await adminConsoleConfigService.buildConfig("clone", cipherId);
let result = await adminConsoleConfigService.buildConfig("clone", cipherId);
expect(result.allowPersonalOwnership).toBe(false); expect(result.allowPersonalOwnership).toBe(false);
policyAppliesToActiveUser$.next(false);
result = await adminConsoleConfigService.buildConfig("clone", cipherId);
expect(result.allowPersonalOwnership).toBe(true);
}); });
describe("getCipher", () => { describe("getCipher", () => {

View File

@@ -4,8 +4,6 @@ import { combineLatest, filter, firstValueFrom, map, switchMap } from "rxjs";
import { CollectionAdminService } from "@bitwarden/admin-console/common"; import { CollectionAdminService } from "@bitwarden/admin-console/common";
import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; 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 { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { CipherId } from "@bitwarden/common/types/guid"; import { CipherId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; 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`. */ /** Admin Console implementation of the `CipherFormConfigService`. */
@Injectable() @Injectable()
export class AdminConsoleCipherFormConfigService implements CipherFormConfigService { export class AdminConsoleCipherFormConfigService implements CipherFormConfigService {
private policyService: PolicyService = inject(PolicyService);
private organizationService: OrganizationService = inject(OrganizationService); private organizationService: OrganizationService = inject(OrganizationService);
private cipherService: CipherService = inject(CipherService); private cipherService: CipherService = inject(CipherService);
private routedVaultFilterService: RoutedVaultFilterService = inject(RoutedVaultFilterService); private routedVaultFilterService: RoutedVaultFilterService = inject(RoutedVaultFilterService);
private collectionAdminService: CollectionAdminService = inject(CollectionAdminService); private collectionAdminService: CollectionAdminService = inject(CollectionAdminService);
private apiService: ApiService = inject(ApiService); private apiService: ApiService = inject(ApiService);
private allowPersonalOwnership$ = this.policyService
.policyAppliesToActiveUser$(PolicyType.PersonalOwnership)
.pipe(map((p) => !p));
private organizationId$ = this.routedVaultFilterService.filter$.pipe( private organizationId$ = this.routedVaultFilterService.filter$.pipe(
map((filter) => filter.organizationId), map((filter) => filter.organizationId),
filter((filter) => filter !== undefined), filter((filter) => filter !== undefined),
@@ -60,8 +53,8 @@ export class AdminConsoleCipherFormConfigService implements CipherFormConfigServ
cipherId?: CipherId, cipherId?: CipherId,
cipherType?: CipherType, cipherType?: CipherType,
): Promise<CipherFormConfig> { ): Promise<CipherFormConfig> {
const [organization, allowPersonalOwnership, allCollections] = await firstValueFrom( const [organization, allCollections] = await firstValueFrom(
combineLatest([this.organization$, this.allowPersonalOwnership$, this.editableCollections$]), combineLatest([this.organization$, this.editableCollections$]),
); );
const cipher = await this.getCipher(organization, cipherId); const cipher = await this.getCipher(organization, cipherId);
@@ -74,7 +67,7 @@ export class AdminConsoleCipherFormConfigService implements CipherFormConfigServ
mode, mode,
cipherType: cipher?.type ?? cipherType ?? CipherType.Login, cipherType: cipher?.type ?? cipherType ?? CipherType.Login,
admin: organization.canEditAllCiphers ?? false, admin: organization.canEditAllCiphers ?? false,
allowPersonalOwnership, allowPersonalOwnership: false,
originalCipher: cipher, originalCipher: cipher,
collections, collections,
organizations: [organization], // only a single org is in context at a time organizations: [organization], // only a single org is in context at a time