diff --git a/src/main/__test__/cluster.test.ts b/src/main/__test__/cluster.test.ts index 52302c7064..6fdf966dfb 100644 --- a/src/main/__test__/cluster.test.ts +++ b/src/main/__test__/cluster.test.ts @@ -38,6 +38,7 @@ import { getFreePort } from "../port"; import { V1ResourceAttributes } from "@kubernetes/client-node"; import { apiResources } from "../../common/rbac"; import request from "request-promise-native" +import { Kubectl } from "../kubectl"; const mockedRequest = request as jest.MockedFunction @@ -73,6 +74,7 @@ describe("create clusters", () => { }) } mockFs(mockOpts) + jest.spyOn(Kubectl.prototype, "ensureKubectl").mockReturnValue(Promise.resolve(true)) }) afterEach(() => { @@ -117,6 +119,7 @@ describe("create clusters", () => { } } + jest.spyOn(Cluster.prototype, "isClusterAdmin").mockReturnValue(Promise.resolve(true)) jest.spyOn(Cluster.prototype, "canI") .mockImplementationOnce((attr: V1ResourceAttributes): Promise => { expect(attr.namespace).toBe("default") @@ -160,6 +163,7 @@ describe("create clusters", () => { expect(c.allowedNamespaces.length).toBe(1) expect(c.allowedResources.length).toBe(apiResources.length) + c.disconnect() jest.resetAllMocks() }) }) diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 3b9e89ef86..cdb2cd2dfd 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -142,6 +142,7 @@ export class Cluster implements ClusterModel { await this.refreshConnectionStatus() if (this.accessible) { await this.refreshAllowedResources() + this.isAdmin = await this.isClusterAdmin() this.ready = true this.kubeCtl = new Kubectl(this.version) this.kubeCtl.ensureKubectl() // download kubectl in background, so it's not blocking dashboard