Skip to content

[PM-16251] Remove ActiveUserState from Policy Service#13231

Merged
BTreston merged 11 commits intomainfrom
ac/PM-16251-vNext-Policy-Service
Feb 24, 2025
Merged

[PM-16251] Remove ActiveUserState from Policy Service#13231
BTreston merged 11 commits intomainfrom
ac/PM-16251-vNext-Policy-Service

Conversation

@BTreston
Copy link
Contributor

@BTreston BTreston commented Feb 3, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-16251

📔 Objective

This PR adds in the vNext implementations of the Policy Service with ActiveUserState references removes. Promise based async functions are refactored to return Observables, and the service is refactored to remove get$ and getAll$. Functions are refactored to expect a UserId as a required param.

This code is not yet wired up, this is only the initial implementation. This will be wired up in followup PRs

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@BTreston BTreston requested a review from a team as a code owner February 3, 2025 19:30
@BTreston BTreston requested a review from JimmyVo16 February 3, 2025 19:30
@BTreston BTreston marked this pull request as draft February 3, 2025 19:30
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2025

Logo
Checkmarx One – Scan Summary & Details6bee6686-cada-47d8-9d3d-3aff256f2036

Great job, no security vulnerabilities found in this Pull Request

@codecov
Copy link

codecov bot commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 58.16327% with 41 lines in your changes missing coverage. Please review.

Project coverage is 35.32%. Comparing base (59ee262) to head (75d3628).
Report is 83 commits behind head on main.

Files with missing lines Patch % Lines
...le/services/policy/default-vnext-policy.service.ts 59.13% 24 Missing and 14 partials ⚠️
...onsole/abstractions/policy/vnext-policy.service.ts 0.00% 2 Missing ⚠️
...dmin-console/services/policy/vnext-policy-state.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13231      +/-   ##
==========================================
+ Coverage   35.29%   35.32%   +0.02%     
==========================================
  Files        3126     3129       +3     
  Lines       92597    92695      +98     
  Branches    16805    16835      +30     
==========================================
+ Hits        32684    32741      +57     
- Misses      57473    57500      +27     
- Partials     2440     2454      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BTreston BTreston marked this pull request as ready for review February 4, 2025 15:30
@BTreston BTreston requested a review from eliykat February 4, 2025 15:30
@BTreston BTreston changed the title initial impl [PM-16251] Remove ActiveUserState from Policy Service Feb 4, 2025
const organization = orgDict[policy.organizationId];

// This shouldn't happen, i.e. the user should only have policies for orgs they are a member of
// But if it does, err on the side of enforcing the policy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking question: is there a way for us to get visibility into this in the rare event it does happen?

I checked Datadog, and it doesn't look like we use RUM. I'm not sure if we're using another monitoring tool for the client side.

Copy link
Member

@eliykat eliykat Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JimmyVo16 : We don't have any observability for front-end errors. (There was an innovation sprint proposal related to this but it was deferred if you want to look it up for context - user privacy is a big issue with logging/analytics.)

JimmyVo16
JimmyVo16 previously approved these changes Feb 5, 2025
const organization = orgDict[policy.organizationId];

// This shouldn't happen, i.e. the user should only have policies for orgs they are a member of
// But if it does, err on the side of enforcing the policy
Copy link
Member

@eliykat eliykat Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JimmyVo16 : We don't have any observability for front-end errors. (There was an innovation sprint proposal related to this but it was deferred if you want to look it up for context - user privacy is a big issue with logging/analytics.)

Comment on lines +313 to +314
describe("policies$", () => {
it("returns all policies", async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests contradicts the next tests: it can't return all policies and not return policies that are disabled or not enforced. As per previous comment this behavior is likely to change, but just consider how the test can be as specific as possible to its intended behavior.

@BTreston BTreston requested a review from eliykat February 6, 2025 22:21
@sonarqubecloud
Copy link

@BTreston BTreston merged commit 9a66aea into main Feb 24, 2025
93 of 94 checks passed
@BTreston BTreston deleted the ac/PM-16251-vNext-Policy-Service branch February 24, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants