cffda99591
BREAKING CHANGES
- Connect-Infisical no longer accepts -ProjectId, -Environment, or -SecretPath.
- InfisicalConnection no longer carries ProjectId, Environment, or DefaultSecretPath.
- Every cmdlet that previously inherited those fields now requires -ProjectId
and/or -Environment as Mandatory=true. -SecretPath / -Path remain optional
and default to "/" at the client layer.
- INFISICAL_PROJECT_ID, INFISICAL_ENVIRONMENT, INFISICAL_SECRET_PATH env-var
scanning removed from Connect-Infisical.
- Resolve{ProjectId,Environment,SecretPath} helpers removed from
InfisicalCmdletBase. ResolveOrganizationId retained.
ADDED
- Get-InfisicalProject -Type <enum> filters the list by product surface
(secret-manager, cert-manager, kms, ssh, secret-scanning, pam, ai) with
IntelliSense via ValidateSet.
- Get-InfisicalProject -IncludeRoles switch maps to includeRoles=true/false
query parameter (always sent).
RATIONALE
- Implicit connection scoping caused 400 Bad Request when the active
connection's ProjectId belonged to a different product surface than the
cmdlet's target (e.g. secret-manager project id passed to /cert-manager/*).
- Explicit parameters make scope unambiguous and make scripts portable
across projects.
- The new -Type filter on Get-InfisicalProject lets callers discover the
correct project id for each subsequent CRUD invocation without needing
connection-level inheritance.
INTERNAL
- All client classes (Secrets / Folders / Environments / Tags / Projects /
Pki) now receive scoping as explicit arguments rather than reading the
InfisicalConnection object.
- Client-layer SecretPath / Path defaulting to "/" is preserved via
FirstNonEmpty(...).
- Help XML updated to remove all "session-pinned" / "active connection"
phrasing; OrderedDictionary splatting examples now include the mandatory
parameters.
- 216/216 unit tests passing.
89 lines
3.2 KiB
C#
89 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Management.Automation;
|
|
using System.Reflection;
|
|
using PSInfisicalAPI.Cmdlets;
|
|
using PSInfisicalAPI.Connections;
|
|
using PSInfisicalAPI.Logging;
|
|
using Xunit;
|
|
|
|
namespace PSInfisicalAPI.Tests
|
|
{
|
|
public class CmdletBaseInheritanceTests
|
|
{
|
|
private sealed class RecordingLogger : IInfisicalLogger
|
|
{
|
|
public List<string> VerboseEntries { get; } = new List<string>();
|
|
|
|
public void Information(string component, string message) { }
|
|
public void Verbose(string component, string message) { VerboseEntries.Add(message); }
|
|
public void Debug(string component, string message) { }
|
|
public void Warning(string component, string message) { }
|
|
public void Error(string component, string message) { }
|
|
}
|
|
|
|
[Cmdlet(VerbsCommon.Get, "TestCmdlet")]
|
|
private sealed class TestCmdlet : InfisicalCmdletBase
|
|
{
|
|
public string CallResolveApiVersion(InfisicalConnection connection, string explicitValue)
|
|
{
|
|
return ResolveApiVersion(connection, explicitValue);
|
|
}
|
|
|
|
public string CallResolveOrganizationId(InfisicalConnection connection, string explicitValue)
|
|
{
|
|
return ResolveOrganizationId(connection, explicitValue);
|
|
}
|
|
}
|
|
|
|
private static TestCmdlet CreateCmdletWith(RecordingLogger logger)
|
|
{
|
|
TestCmdlet cmdlet = new TestCmdlet();
|
|
FieldInfo field = typeof(InfisicalCmdletBase).GetField("_logger", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
field.SetValue(cmdlet, logger);
|
|
return cmdlet;
|
|
}
|
|
|
|
private static InfisicalConnection ConnectionWithDefaults()
|
|
{
|
|
return new InfisicalConnection
|
|
{
|
|
BaseUri = new Uri("https://app.example.com"),
|
|
OrganizationId = "org-conn",
|
|
PinnedApiVersion = "v3"
|
|
};
|
|
}
|
|
|
|
[Fact]
|
|
public void ResolveApiVersion_Prefers_PinnedApiVersion_From_Connection()
|
|
{
|
|
RecordingLogger logger = new RecordingLogger();
|
|
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
|
|
|
string resolved = cmdlet.CallResolveApiVersion(ConnectionWithDefaults(), null);
|
|
Assert.Equal("v3", resolved);
|
|
}
|
|
|
|
[Fact]
|
|
public void ResolveOrganizationId_Inherits_From_Connection_And_Logs()
|
|
{
|
|
RecordingLogger logger = new RecordingLogger();
|
|
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
|
|
|
Assert.Equal("org-conn", cmdlet.CallResolveOrganizationId(ConnectionWithDefaults(), null));
|
|
Assert.Single(logger.VerboseEntries);
|
|
Assert.Contains("OrganizationId", logger.VerboseEntries[0]);
|
|
}
|
|
|
|
[Fact]
|
|
public void ResolveOrganizationId_Explicit_Value_Wins_And_Does_Not_Log()
|
|
{
|
|
RecordingLogger logger = new RecordingLogger();
|
|
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
|
|
|
Assert.Equal("explicit-org", cmdlet.CallResolveOrganizationId(ConnectionWithDefaults(), "explicit-org"));
|
|
Assert.Empty(logger.VerboseEntries);
|
|
}
|
|
}
|
|
}
|