Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions OnePassword.NET.Tests/OnePasswordManagerCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO.Compression;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
using OnePassword.Common;
using OnePassword.Documents;
using OnePassword.Items;
Expand Down Expand Up @@ -281,6 +282,30 @@ public void EditItemFailureKeepsItemDirty()
Assert.That(IsTrackedChanged(item), Is.True);
}

[Test]
public void EditItemPreservesCustomTemplateCategoryIdInPayload()
{
using var fakeCli = new FakeCli();
var manager = fakeCli.CreateManager();
var item = CreateTrackedItem("item-id", "Custom Item");
item.CategoryId = "custom-template-uuid";
item.Fields.Add(new Field("Environment", FieldType.String, "Production"));

manager.EditItem(item, "vault-id");

using var jsonDocument = JsonDocument.Parse(fakeCli.LastInput);
var root = jsonDocument.RootElement;
var fields = root.GetProperty("fields").EnumerateArray().ToList();

Assert.Multiple(() =>
{
Assert.That(root.GetProperty("category_id").GetString(), Is.EqualTo("custom-template-uuid"));
Assert.That(fields.Any(field =>
field.GetProperty("label").GetString() == "Environment"
&& field.GetProperty("value").GetString() == "Production"), Is.True);
});
}

[Test]
public void ShareItemWithoutEmailsOmitsEmailsFlag()
{
Expand Down Expand Up @@ -416,6 +441,7 @@ private sealed class FakeCli : IDisposable
private readonly string _argumentsPath;
private readonly string _directoryPath;
private readonly string _errorOutputPath;
private readonly string _inputPath;
private readonly string _nextOutputPath;
private readonly string _updateMessagePath;
private readonly string _updatePayloadPath;
Expand All @@ -427,6 +453,7 @@ public FakeCli(string versionOutput = "2.32.1\n", string nextOutput = "{}", stri
_directoryPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
_argumentsPath = Path.Combine(_directoryPath, "last-arguments.txt");
_errorOutputPath = Path.Combine(_directoryPath, "error-output.txt");
_inputPath = Path.Combine(_directoryPath, "last-input.txt");
_nextOutputPath = Path.Combine(_directoryPath, "next-output.txt");
_updateMessagePath = Path.Combine(_directoryPath, "update-output.txt");
_updatePayloadPath = Path.Combine(_directoryPath, "update-payload.zip");
Expand Down Expand Up @@ -460,6 +487,8 @@ public FakeCli(string versionOutput = "2.32.1\n", string nextOutput = "{}", stri

public string LastArguments => File.Exists(_argumentsPath) ? File.ReadAllText(_argumentsPath) : "";

public string LastInput => File.Exists(_inputPath) ? File.ReadAllText(_inputPath) : "";

public OnePasswordManager CreateManager()
{
return new OnePasswordManager(options =>
Expand Down Expand Up @@ -500,6 +529,7 @@ private static string GetScript(string versionOutputFileName)
@echo off
setlocal
> "%~dp0last-arguments.txt" echo %*
> "%~dp0last-input.txt" more
if "%~1"=="update" (
if exist "%~dp0update-payload.zip" copy /y "%~dp0update-payload.zip" "%~3\update-payload.zip" > nul
if exist "%~dp0update-output.txt" type "%~dp0update-output.txt"
Expand All @@ -519,6 +549,7 @@ @echo off
#!/bin/sh
script_dir=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
printf '%s' "$*" > "$script_dir/last-arguments.txt"
cat > "$script_dir/last-input.txt"
if [ "$1" = "update" ]; then
if [ -f "$script_dir/update-payload.zip" ]; then
cp "$script_dir/update-payload.zip" "$3/update-payload.zip"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ itemToExtend.Fields.Add(new Field("Environment", FieldType.String, "Production")
onePassword.EditItem(itemToExtend, vault);
```

The same hydrate-edit-save flow applies to items based on custom templates. Fetch the hydrated item with `GetItem(...)` before editing so the wrapper preserves the item's template-backed `category_id` in the edit payload.

### Adding file attachments to an item

```csharp
Expand Down
51 changes: 3 additions & 48 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,7 @@
# TODO

Current snapshot as of 2026-03-08.
Current snapshot as of 2026-03-09.

Historical debugging notes and completed issue/PR triage were removed from this file after the related work landed. The remaining current items are below.
Historical debugging notes and completed issue/PR triage were removed from this file after the related work landed.

## Priority Order

1. Decide whether to merge, supersede, or close PR #84.
2. Verify whether Issue #85 still reproduces for custom-template items.

## Open Pull Requests

### PR #84 - Add Support for Referencing Files Object in Item Class

Link:
- https://github.com/jscarle/OnePassword.NET/pull/84

Current assessment:
- Still lower priority than the bug-fix work already merged.
- Additive and potentially useful, but not merge-ready as-is.
- The PR only adds read-only file metadata exposure.

Outstanding concerns:
- No tests were added.
- No README or docfx documentation was added.
- The public type name `File` is easy to confuse with `System.IO.File`.

Recommended next step:
- If attachment metadata matters soon, either update PR #84 or reimplement it with:
- deserialization coverage for the `files` payload
- documentation that the feature is read-only metadata
- explicit consideration of the public type name
- Otherwise, leave it deferred.

## Open Issues

### Issue #85 - Example on how to add Fields to an existing item?

Link:
- https://github.com/jscarle/OnePassword.NET/issues/85

Current assessment:
- The built-in item flow is now covered and documented:
- `OnePassword.NET.Tests/TestItems.cs` includes `EditItemAddsNewField()`
- `README.md` and `docfx/docs/quick-start.md` show hydrating with `GetItem(...)` before adding a field
- The remaining uncertainty is the issue comment pointing to custom-template behavior related to PR #81.

Recommended next step:
- Reproduce the scenario specifically against a custom-template item.
- If it does not reproduce, close the issue as stale or already addressed by current behavior and docs.
- If it does reproduce, treat it as a targeted custom-template compatibility bug and add focused regression coverage before changing product code.
There are no active engineering follow-up items currently tracked in this file.
2 changes: 2 additions & 0 deletions docfx/docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ itemToExtend.Fields.Add(new Field("Environment", FieldType.String, "Production")
onePassword.EditItem(itemToExtend, vault);
```

The same hydrate-edit-save flow applies to items based on custom templates. Fetch the hydrated item with `GetItem(...)` before editing so the wrapper preserves the item's template-backed `category_id` in the edit payload.

### Adding file attachments to an item

```csharp
Expand Down
Loading