mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Test is user cluster admin on cluster activate (#1116)
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
4a15e65fea
commit
2a9d39a8b9
@ -38,6 +38,7 @@ import { getFreePort } from "../port";
|
|||||||
import { V1ResourceAttributes } from "@kubernetes/client-node";
|
import { V1ResourceAttributes } from "@kubernetes/client-node";
|
||||||
import { apiResources } from "../../common/rbac";
|
import { apiResources } from "../../common/rbac";
|
||||||
import request from "request-promise-native"
|
import request from "request-promise-native"
|
||||||
|
import { Kubectl } from "../kubectl";
|
||||||
|
|
||||||
const mockedRequest = request as jest.MockedFunction<typeof request>
|
const mockedRequest = request as jest.MockedFunction<typeof request>
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ describe("create clusters", () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
mockFs(mockOpts)
|
mockFs(mockOpts)
|
||||||
|
jest.spyOn(Kubectl.prototype, "ensureKubectl").mockReturnValue(Promise.resolve(true))
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -117,6 +119,7 @@ describe("create clusters", () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jest.spyOn(Cluster.prototype, "isClusterAdmin").mockReturnValue(Promise.resolve(true))
|
||||||
jest.spyOn(Cluster.prototype, "canI")
|
jest.spyOn(Cluster.prototype, "canI")
|
||||||
.mockImplementationOnce((attr: V1ResourceAttributes): Promise<boolean> => {
|
.mockImplementationOnce((attr: V1ResourceAttributes): Promise<boolean> => {
|
||||||
expect(attr.namespace).toBe("default")
|
expect(attr.namespace).toBe("default")
|
||||||
@ -160,6 +163,7 @@ describe("create clusters", () => {
|
|||||||
expect(c.allowedNamespaces.length).toBe(1)
|
expect(c.allowedNamespaces.length).toBe(1)
|
||||||
expect(c.allowedResources.length).toBe(apiResources.length)
|
expect(c.allowedResources.length).toBe(apiResources.length)
|
||||||
|
|
||||||
|
c.disconnect()
|
||||||
jest.resetAllMocks()
|
jest.resetAllMocks()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -142,6 +142,7 @@ export class Cluster implements ClusterModel {
|
|||||||
await this.refreshConnectionStatus()
|
await this.refreshConnectionStatus()
|
||||||
if (this.accessible) {
|
if (this.accessible) {
|
||||||
await this.refreshAllowedResources()
|
await this.refreshAllowedResources()
|
||||||
|
this.isAdmin = await this.isClusterAdmin()
|
||||||
this.ready = true
|
this.ready = true
|
||||||
this.kubeCtl = new Kubectl(this.version)
|
this.kubeCtl = new Kubectl(this.version)
|
||||||
this.kubeCtl.ensureKubectl() // download kubectl in background, so it's not blocking dashboard
|
this.kubeCtl.ensureKubectl() // download kubectl in background, so it's not blocking dashboard
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user