feat: add Gemini ADC and access token auth (#312)
* feat: add Gemini ADC and access token auth * feat: add Gemini token and ADC provider setup * feat: add Gemini token and ADC provider setup * fix: honor Gemini auth mode on restart
This commit is contained in:
@@ -25,24 +25,24 @@ describe("Secure Storage Platform Implementations", () => {
|
||||
process.env = originalEnv;
|
||||
});
|
||||
|
||||
const testData = {
|
||||
mcpOAuth: {
|
||||
"test-server": {
|
||||
accessToken: "secret-token",
|
||||
expiresAt: 123456789,
|
||||
serverName: "test",
|
||||
serverUrl: "http://test"
|
||||
}
|
||||
}
|
||||
const testData = {
|
||||
mcpOAuth: {
|
||||
"test-server": {
|
||||
accessToken: "secret-token",
|
||||
expiresAt: 123456789,
|
||||
serverName: "test",
|
||||
serverUrl: "http://test"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
describe("Config-Dir Isolation", () => {
|
||||
test("service name changes with CLAUDE_CONFIG_DIR", () => {
|
||||
const defaultName = getSecureStorageServiceName(CREDENTIALS_SERVICE_SUFFIX);
|
||||
|
||||
|
||||
process.env.CLAUDE_CONFIG_DIR = "/tmp/other-config";
|
||||
const otherName = getSecureStorageServiceName(CREDENTIALS_SERVICE_SUFFIX);
|
||||
|
||||
|
||||
expect(otherName).not.toBe(defaultName);
|
||||
expect(otherName).toContain("Claude Code");
|
||||
expect(otherName).toContain(CREDENTIALS_SERVICE_SUFFIX);
|
||||
@@ -51,9 +51,9 @@ describe("Secure Storage Platform Implementations", () => {
|
||||
test("Linux storage uses scoped service name", () => {
|
||||
process.env.CLAUDE_CONFIG_DIR = "/tmp/linux-scoped";
|
||||
const expectedName = getSecureStorageServiceName(CREDENTIALS_SERVICE_SUFFIX);
|
||||
|
||||
|
||||
linuxSecretStorage.update(testData);
|
||||
|
||||
|
||||
const args = mockExecaSync.mock.calls[0];
|
||||
expect(args[1]).toContain(expectedName);
|
||||
});
|
||||
@@ -61,9 +61,9 @@ describe("Secure Storage Platform Implementations", () => {
|
||||
test("Windows storage uses scoped resource name", () => {
|
||||
process.env.CLAUDE_CONFIG_DIR = "/tmp/win-scoped";
|
||||
const expectedName = getSecureStorageServiceName(CREDENTIALS_SERVICE_SUFFIX);
|
||||
|
||||
|
||||
windowsCredentialStorage.update(testData);
|
||||
|
||||
|
||||
const script = mockExecaSync.mock.calls[0][1][1];
|
||||
expect(script).toContain(expectedName);
|
||||
expect(script).toContain("Add-Type -AssemblyName System.Runtime.WindowsRuntime");
|
||||
@@ -72,19 +72,19 @@ describe("Secure Storage Platform Implementations", () => {
|
||||
|
||||
describe("Windows PowerShell Escaping", () => {
|
||||
test("escapes single quotes and prevents $ expansion", () => {
|
||||
const dataWithDollar = {
|
||||
mcpOAuth: {
|
||||
"server": {
|
||||
const dataWithDollar = {
|
||||
mcpOAuth: {
|
||||
"server": {
|
||||
accessToken: "token-with-$env:USERNAME",
|
||||
expiresAt: 123,
|
||||
serverName: "s",
|
||||
serverUrl: "u"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
windowsCredentialStorage.update(dataWithDollar);
|
||||
|
||||
|
||||
const script = mockExecaSync.mock.calls[0][1][1];
|
||||
// Should use single quotes for the payload
|
||||
expect(script).toMatch(/'\{.*\}'/);
|
||||
@@ -92,7 +92,7 @@ describe("Secure Storage Platform Implementations", () => {
|
||||
expect(script).not.toContain("'token-with-$env:USERNAME'");
|
||||
// But since it's JSON, the value will be "token-with-$env:USERNAME" inside the single-quoted string
|
||||
// The JSON itself shouldn't have single quotes unless the data has them.
|
||||
|
||||
|
||||
const dataWithQuote = { mcpOAuth: { "s": { accessToken: "token'quote", expiresAt: 1, serverName: "s", serverUrl: "u" } } };
|
||||
windowsCredentialStorage.update(dataWithQuote);
|
||||
const script2 = mockExecaSync.mock.calls[1][1][1];
|
||||
@@ -117,7 +117,7 @@ describe("Secure Storage Platform Implementations", () => {
|
||||
describe("Linux secret-tool Interaction", () => {
|
||||
test("update passes payload via stdin", () => {
|
||||
linuxSecretStorage.update(testData);
|
||||
|
||||
|
||||
const options = mockExecaSync.mock.calls[0][2];
|
||||
expect(options.input).toContain("secret-token");
|
||||
});
|
||||
@@ -125,7 +125,7 @@ describe("Secure Storage Platform Implementations", () => {
|
||||
test("read parses stdout", () => {
|
||||
mockExecaSync.mockReturnValue({ exitCode: 0, stdout: JSON.stringify(testData) });
|
||||
const result = linuxSecretStorage.read();
|
||||
|
||||
|
||||
expect(result).toEqual(testData);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user