Skip to content

Commit 03f405e

Browse files
committed
fix: use urls from official doc
1 parent 1916169 commit 03f405e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/lib/ggshield-configuration.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ export class GGShieldConfiguration {
99
allowSelfSigned: boolean = false
1010
) {
1111
this.ggshieldPath = ggshieldPath;
12-
this.apiUrl = apiUrl;
1312
this.allowSelfSigned = allowSelfSigned;
13+
if (apiUrl === "https://api.gitguardian.com/v1") {
14+
this.apiUrl = "https://dashboard.gitguardian.com/v1";
15+
} else if (apiUrl === "https://api.eu1.gitguardian.com/v1") {
16+
this.apiUrl = "https://dashboard.eu1.gitguardian.com/v1";
17+
}
18+
else {
19+
this.apiUrl = apiUrl;
20+
}
1421
}
1522
}
1623

src/test/suite/lib/ggshield-configuration-utils.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,27 @@ suite("getConfiguration", () => {
4040
assert.strictEqual(configuration.apiUrl, "https://custom-url.com");
4141
assert.strictEqual(configuration.allowSelfSigned, true);
4242
});
43+
44+
test("API url is correctly replaced with dashboard urlg for EU customers", () => {
45+
const context = {} as ExtensionContext;
46+
simple.mock(context, "asAbsolutePath").returnWith("");
47+
getConfigurationMock.returnWith({
48+
get: (key: string) => {
49+
if (key === "apiUrl") {
50+
return "https://api.eu1.gitguardian.com/v1";
51+
}
52+
},
53+
});
54+
const configuration = getConfiguration(context);
55+
56+
// Assert both workspace.getConfiguration and GGShieldConfiguration constructor were called
57+
assert(
58+
getConfigurationMock.called,
59+
"getConfiguration should be called once"
60+
);
61+
62+
// Assert that the configuration has the expected values
63+
assert.strictEqual(configuration.apiUrl, "https://dashboard.eu1.gitguardian.com/v1");
64+
});
65+
4366
});

0 commit comments

Comments
 (0)