diff --git a/src/common/__tests__/cluster-store.test.ts b/src/common/__tests__/cluster-store.test.ts index ee93106adf..3983918c40 100644 --- a/src/common/__tests__/cluster-store.test.ts +++ b/src/common/__tests__/cluster-store.test.ts @@ -334,159 +334,6 @@ users: }); }); - describe("pre 2.0 config with an existing cluster", () => { - beforeEach(() => { - ClusterStore.resetInstance(); - - const mockOpts = { - "some-directory-for-user-data": { - "lens-cluster-store.json": JSON.stringify({ - __internal__: { - migrations: { - version: "1.0.0", - }, - }, - cluster1: minimalValidKubeConfig, - }), - }, - }; - - mockFs(mockOpts); - - clusterStore = mainDi.inject(clusterStoreInjectable); - }); - - afterEach(() => { - mockFs.restore(); - }); - - it("migrates to modern format with kubeconfig in a file", async () => { - const config = clusterStore.clustersList[0].kubeConfigPath; - - expect(fs.readFileSync(config, "utf8")).toContain(`"contexts":[`); - }); - }); - - describe("pre 2.6.0 config with a cluster that has arrays in auth config", () => { - beforeEach(() => { - ClusterStore.resetInstance(); - const mockOpts = { - "some-directory-for-user-data": { - "lens-cluster-store.json": JSON.stringify({ - __internal__: { - migrations: { - version: "2.4.1", - }, - }, - cluster1: { - kubeConfig: JSON.stringify({ - apiVersion: "v1", - clusters: [ - { - cluster: { - server: "https://10.211.55.6:8443", - }, - name: "minikube", - }, - ], - contexts: [ - { - context: { - cluster: "minikube", - user: "minikube", - name: "minikube", - }, - name: "minikube", - }, - ], - "current-context": "minikube", - kind: "Config", - preferences: {}, - users: [ - { - name: "minikube", - user: { - "client-certificate": "/Users/foo/.minikube/client.crt", - "client-key": "/Users/foo/.minikube/client.key", - "auth-provider": { - config: { - "access-token": ["should be string"], - expiry: ["should be string"], - }, - }, - }, - }, - ], - }), - }, - }), - }, - }; - - mockFs(mockOpts); - - clusterStore = mainDi.inject(clusterStoreInjectable); - }); - - afterEach(() => { - mockFs.restore(); - }); - - it("replaces array format access token and expiry into string", async () => { - const file = clusterStore.clustersList[0].kubeConfigPath; - const config = fs.readFileSync(file, "utf8"); - const kc = yaml.load(config) as Record; - - expect(kc.users[0].user["auth-provider"].config["access-token"]).toBe( - "should be string", - ); - expect(kc.users[0].user["auth-provider"].config["expiry"]).toBe( - "should be string", - ); - }); - }); - - describe("pre 2.6.0 config with a cluster icon", () => { - beforeEach(() => { - ClusterStore.resetInstance(); - const mockOpts = { - "some-directory-for-user-data": { - "lens-cluster-store.json": JSON.stringify({ - __internal__: { - migrations: { - version: "2.4.1", - }, - }, - cluster1: { - kubeConfig: minimalValidKubeConfig, - icon: "icon_path", - preferences: { - terminalCWD: "/some-directory-for-user-data", - }, - }, - }), - icon_path: testDataIcon, - }, - }; - - mockFs(mockOpts); - - clusterStore = mainDi.inject(clusterStoreInjectable); - }); - - afterEach(() => { - mockFs.restore(); - }); - - it("moves the icon into preferences", async () => { - const storedClusterData = clusterStore.clustersList[0]; - - expect(Object.prototype.hasOwnProperty.call(storedClusterData, "icon")).toBe(false); - expect(Object.prototype.hasOwnProperty.call(storedClusterData.preferences, "icon")).toBe(true); - expect(storedClusterData.preferences.icon.startsWith("data:;base64,")).toBe(true); - }); - }); - describe("pre 3.6.0-beta.1 config with an existing cluster", () => { beforeEach(() => { ClusterStore.resetInstance();