Skip to content

Commit

Permalink
fix: use urls from official doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Séverine Bonnechère committed Dec 30, 2024
1 parent 1916169 commit 03f405e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/ggshield-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ export class GGShieldConfiguration {
allowSelfSigned: boolean = false
) {
this.ggshieldPath = ggshieldPath;
this.apiUrl = apiUrl;
this.allowSelfSigned = allowSelfSigned;
if (apiUrl === "https://api.gitguardian.com/v1") {
this.apiUrl = "https://dashboard.gitguardian.com/v1";
} else if (apiUrl === "https://api.eu1.gitguardian.com/v1") {
this.apiUrl = "https://dashboard.eu1.gitguardian.com/v1";
}
else {
this.apiUrl = apiUrl;
}
}
}

23 changes: 23 additions & 0 deletions src/test/suite/lib/ggshield-configuration-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,27 @@ suite("getConfiguration", () => {
assert.strictEqual(configuration.apiUrl, "https://custom-url.com");
assert.strictEqual(configuration.allowSelfSigned, true);
});

test("API url is correctly replaced with dashboard urlg for EU customers", () => {
const context = {} as ExtensionContext;
simple.mock(context, "asAbsolutePath").returnWith("");
getConfigurationMock.returnWith({
get: (key: string) => {
if (key === "apiUrl") {
return "https://api.eu1.gitguardian.com/v1";
}
},
});
const configuration = getConfiguration(context);

// Assert both workspace.getConfiguration and GGShieldConfiguration constructor were called
assert(
getConfigurationMock.called,
"getConfiguration should be called once"
);

// Assert that the configuration has the expected values
assert.strictEqual(configuration.apiUrl, "https://dashboard.eu1.gitguardian.com/v1");
});

});

0 comments on commit 03f405e

Please sign in to comment.