Skip to content

PM-23649: CXF Import note #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 14, 2025
Merged

PM-23649: CXF Import note #382

merged 7 commits into from
Aug 14, 2025

Conversation

abergs
Copy link
Member

@abergs abergs commented Aug 13, 2025

🎟️ Tracking

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

📔 Objective

This PR maps the Note type, and adds mapping the note for existing vault items.

Note: A separate task has been created to track that we're mapping notes for all other cipheritems (some are not created yet).

⏰ 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

@abergs abergs requested a review from a team as a code owner August 13, 2025 09:17
@abergs abergs requested review from addisonbeck and Hinton and removed request for addisonbeck August 13, 2025 09:17
Copy link
Contributor

github-actions bot commented Aug 13, 2025

Logo
Checkmarx One – Scan Summary & Details7d39dea7-10e2-4c8b-92bf-aa0391affba7

Great job! No new security vulnerabilities introduced in this pull request

Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 98.22222% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.61%. Comparing base (4153278) to head (3a44a16).
⚠️ Report is 1 commits behind head on cxf/sample.

Files with missing lines Patch % Lines
crates/bitwarden-exporters/src/cxf/note.rs 97.94% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           cxf/sample     #382      +/-   ##
==============================================
+ Coverage       74.37%   74.61%   +0.23%     
==============================================
  Files             253      254       +1     
  Lines           21918    22138     +220     
==============================================
+ Hits            16302    16518     +216     
- Misses           5616     5620       +4     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@abergs abergs changed the title Implement note.rs PM-23649: CXF Import note Aug 13, 2025
Comment on lines 78 to 258

assert_eq!(cipher.fields.len(), 0); // Notes don't have custom fields
}

#[test]
fn test_note_as_part_of_login() {
use credential_exchange_format::{BasicAuthCredential, Credential, Item};

use crate::{cxf::import::parse_item, CipherType, ImportingCipher};

let item = Item {
id: [0, 1, 2, 3, 4, 5, 6].as_ref().into(),
creation_at: Some(1706613834),
modified_at: Some(1706623773),
title: "Login with Note".to_string(),
subtitle: None,
favorite: None,
credentials: vec![
Credential::BasicAuth(Box::new(BasicAuthCredential {
username: Some("testuser".to_string().into()),
password: Some("testpass".to_string().into()),
})),
Credential::Note(Box::new(NoteCredential {
content: "This note should be added to the login cipher."
.to_string()
.into(),
})),
],
tags: None,
extensions: None,
scope: None,
};

let ciphers: Vec<ImportingCipher> = parse_item(item);
assert_eq!(ciphers.len(), 1); // Should create only one cipher (Login with note content)
let cipher = ciphers.first().unwrap();

assert_eq!(cipher.name, "Login with Note");
assert_eq!(
cipher.notes,
Some("This note should be added to the login cipher.".to_string())
);

match &cipher.r#type {
CipherType::Login(_) => (), // Should be a Login cipher
_ => panic!("Expected Login cipher with note content"),
};
}

#[test]
fn test_note_as_part_of_api_key() {
use credential_exchange_format::{ApiKeyCredential, Credential, Item};

use crate::{cxf::import::parse_item, CipherType, ImportingCipher};

let item = Item {
id: [0, 1, 2, 3, 4, 5, 6].as_ref().into(),
creation_at: Some(1706613834),
modified_at: Some(1706623773),
title: "API Key with Note".to_string(),
subtitle: None,
favorite: None,
credentials: vec![
Credential::ApiKey(Box::new(ApiKeyCredential {
key: Some("api-key-12345".to_string().into()),
username: Some("api-user".to_string().into()),
key_type: Some("Bearer".to_string().into()),
url: None,
valid_from: None,
expiry_date: None,
})),
Credential::Note(Box::new(NoteCredential {
content: "This note should be added to the API key cipher."
.to_string()
.into(),
})),
],
tags: None,
extensions: None,
scope: None,
};

let ciphers: Vec<ImportingCipher> = parse_item(item);
assert_eq!(ciphers.len(), 1); // Should create only one cipher (SecureNote with note content)
let cipher = ciphers.first().unwrap();

assert_eq!(cipher.name, "API Key with Note");
assert_eq!(
cipher.notes,
Some("This note should be added to the API key cipher.".to_string())
);

match &cipher.r#type {
CipherType::SecureNote(_) => (), // Should be a SecureNote cipher
_ => panic!("Expected SecureNote cipher with note content"),
};

// Should have API key fields
assert!(!cipher.fields.is_empty());
}
Copy link
Member

Choose a reason for hiding this comment

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

issue: This is testing the import logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it does, but that's because the way we handle notes are kind tied into the import logic. The reason I'm keeping it in note.rs is because the whole world falls on my head in terms of merge conflicts if I don't while I do these separate PRs. I'm happy to move refactor the tests once all the mapping is in the same branch.

@abergs abergs requested a review from Hinton August 14, 2025 12:35
Copy link

Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

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

Let's merge this into sample and we can refine it there.

@abergs abergs merged commit acea084 into cxf/sample Aug 14, 2025
49 checks passed
@abergs abergs deleted the cxf/note branch August 14, 2025 14:55
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.

2 participants