-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove che-workspace-client lib
Signed-off-by: Oleksii Orel <oorel@redhat.com>
- Loading branch information
Showing
78 changed files
with
525 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,3 @@ | |
display: inline-block; | ||
padding-top: 8px; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
packages/dashboard-frontend/src/services/backend-client/__tests__/factoryApi.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright (c) 2018-2023 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import mockAxios from 'axios'; | ||
import { getFactoryResolver, refreshFactoryOauthToken } from '../factoryApi'; | ||
import { FactoryResolver } from '../../helpers/types'; | ||
import devfileApi from '../../devfileApi'; | ||
|
||
describe('Factory API', () => { | ||
const mockPost = mockAxios.post as jest.Mock; | ||
|
||
const location = 'https://github.com/eclipse-che/che-dashboard.git'; | ||
const factoryResolver: FactoryResolver = { | ||
v: '4.0', | ||
source: 'devfile.yaml', | ||
scm_info: { | ||
clone_url: location, | ||
scm_provider: 'github', | ||
}, | ||
devfile: { | ||
schemaVersion: '2.2.1', | ||
metadata: { | ||
name: 'che-dashboard', | ||
namespace: 'namespace', | ||
}, | ||
projects: [ | ||
{ | ||
git: { | ||
remotes: { | ||
origin: 'https://github.com/eclipse-che/che-dashboard.git', | ||
}, | ||
}, | ||
name: 'che-dashboard', | ||
}, | ||
], | ||
} as devfileApi.Devfile, | ||
links: [], | ||
}; | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe('resolve factory', () => { | ||
it('should call "/factory/resolver"', async () => { | ||
mockPost.mockResolvedValueOnce({ | ||
data: expect.anything(), | ||
}); | ||
await getFactoryResolver(location, {}); | ||
|
||
expect(mockPost).toBeCalledWith('/api/factory/resolver', { | ||
url: 'https://github.com/eclipse-che/che-dashboard.git', | ||
}); | ||
}); | ||
|
||
it('should return a factory resolver', async () => { | ||
mockPost.mockResolvedValueOnce({ | ||
data: factoryResolver, | ||
}); | ||
|
||
const res = await getFactoryResolver(location, {}); | ||
|
||
expect(res).toEqual(factoryResolver); | ||
}); | ||
}); | ||
|
||
describe('refresh factory OAuth token', () => { | ||
it('should call "/api/factory/token/refresh?url=${url}"', async () => { | ||
mockPost.mockResolvedValueOnce({ | ||
data: expect.anything(), | ||
}); | ||
|
||
await refreshFactoryOauthToken(location); | ||
|
||
expect(mockPost).toBeCalledWith( | ||
'/api/factory/token/refresh?url=https://github.com/eclipse-che/che-dashboard.git', | ||
); | ||
}); | ||
|
||
it('should return the OAuth token', async () => { | ||
mockPost.mockResolvedValueOnce(undefined); | ||
|
||
const res = await refreshFactoryOauthToken(location); | ||
|
||
expect(res).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
69 changes: 69 additions & 0 deletions
69
.../dashboard-frontend/src/services/backend-client/__tests__/kubernetesNamespaceApi.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2018-2023 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import mockAxios from 'axios'; | ||
import { getKubernetesNamespace, provisionKubernetesNamespace } from '../kubernetesNamespaceApi'; | ||
|
||
describe('Kubernetes namespace API', () => { | ||
const mockGet = mockAxios.get as jest.Mock; | ||
const mockPost = mockAxios.post as jest.Mock; | ||
|
||
const namespace: che.KubernetesNamespace = { name: 'test-name', attributes: { phase: 'Active' } }; | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe('fetch namespace', () => { | ||
it('should call "/api/kubernetes/namespace"', async () => { | ||
mockGet.mockResolvedValueOnce({ | ||
data: expect.anything(), | ||
}); | ||
await getKubernetesNamespace(); | ||
|
||
expect(mockGet).toBeCalledWith('/api/kubernetes/namespace'); | ||
expect(mockPost).not.toBeCalled(); | ||
}); | ||
|
||
it('should return a list of namespaces', async () => { | ||
mockGet.mockResolvedValueOnce({ | ||
data: [namespace], | ||
}); | ||
|
||
const res = await getKubernetesNamespace(); | ||
|
||
expect(res).toEqual([namespace]); | ||
}); | ||
}); | ||
|
||
describe('provision namespace', () => { | ||
it('should call "/api/kubernetes/namespace/provision"', async () => { | ||
mockPost.mockResolvedValueOnce({ | ||
data: expect.anything(), | ||
}); | ||
await provisionKubernetesNamespace(); | ||
|
||
expect(mockGet).not.toBeCalled(); | ||
expect(mockPost).toBeCalledWith('/api/kubernetes/namespace/provision'); | ||
}); | ||
|
||
it('should return a list of namespaces', async () => { | ||
mockPost.mockResolvedValueOnce({ | ||
data: [namespace], | ||
}); | ||
|
||
const res = await provisionKubernetesNamespace(); | ||
|
||
expect(res).toEqual([namespace]); | ||
}); | ||
}); | ||
}); |
93 changes: 93 additions & 0 deletions
93
packages/dashboard-frontend/src/services/backend-client/__tests__/oAuthApi.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2018-2023 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import mockAxios from 'axios'; | ||
import { IGitOauth } from '../../../store/GitOauthConfig/types'; | ||
import { deleteOAuthToken, getOAuthProviders, getOAuthToken } from '../oAuthApi'; | ||
|
||
describe('Open Authorization API', () => { | ||
const mockGet = mockAxios.get as jest.Mock; | ||
const mockDelete = mockAxios.delete as jest.Mock; | ||
|
||
const oAuthProvider = { name: 'github', endpointUrl: 'https://github.com' } as IGitOauth; | ||
const oAuthProviderToken = { token: 'dummy_token' }; | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe('fetch OAuthProviders', () => { | ||
it('should call "/api/oauth"', async () => { | ||
mockGet.mockResolvedValueOnce({ | ||
data: expect.anything(), | ||
}); | ||
await getOAuthProviders(); | ||
|
||
expect(mockDelete).not.toBeCalled(); | ||
expect(mockGet).toBeCalledWith('/api/oauth'); | ||
}); | ||
|
||
it('should return a list of providers', async () => { | ||
mockGet.mockResolvedValueOnce({ | ||
data: [oAuthProvider], | ||
}); | ||
|
||
const res = await getOAuthProviders(); | ||
|
||
expect(res).toEqual([oAuthProvider]); | ||
}); | ||
}); | ||
|
||
describe('fetch OAuthToken', () => { | ||
it('should call "/api/oauth/token?oauth_provider=github"', async () => { | ||
mockGet.mockResolvedValueOnce({ | ||
data: expect.anything(), | ||
}); | ||
|
||
await getOAuthToken(oAuthProvider.name); | ||
|
||
expect(mockDelete).not.toBeCalled(); | ||
expect(mockGet).toBeCalledWith('/api/oauth/token?oauth_provider=github'); | ||
}); | ||
|
||
it('should return the OAuth token', async () => { | ||
mockGet.mockResolvedValueOnce({ | ||
data: oAuthProviderToken, | ||
}); | ||
|
||
const res = await getOAuthToken(oAuthProvider.name); | ||
|
||
expect(mockDelete).not.toBeCalled(); | ||
expect(res).toEqual(oAuthProviderToken); | ||
}); | ||
}); | ||
|
||
describe('delete OAuthToken', () => { | ||
it('should call "/api/oauth/token?oauth_provider=github"', async () => { | ||
mockDelete.mockResolvedValueOnce(undefined); | ||
|
||
await deleteOAuthToken(oAuthProvider.name); | ||
|
||
expect(mockGet).not.toBeCalled(); | ||
expect(mockDelete).toBeCalledWith('/api/oauth/token?oauth_provider=github'); | ||
}); | ||
|
||
it('should return undefined', async () => { | ||
mockDelete.mockResolvedValueOnce(undefined); | ||
|
||
const res = await deleteOAuthToken(oAuthProvider.name); | ||
|
||
expect(mockGet).not.toBeCalled(); | ||
expect(res).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
packages/dashboard-frontend/src/services/backend-client/kubernetesNamespaceApi.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2018-2023 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
|
||
import axios from 'axios'; | ||
import { cheServerPrefix } from './const'; | ||
|
||
export async function getKubernetesNamespace(): Promise<che.KubernetesNamespace[]> { | ||
const response = await axios.get(`${cheServerPrefix}/kubernetes/namespace`); | ||
|
||
return response.data; | ||
} | ||
|
||
export async function provisionKubernetesNamespace(): Promise<che.KubernetesNamespace> { | ||
const response = await axios.post(`${cheServerPrefix}/kubernetes/namespace/provision`); | ||
|
||
return response.data; | ||
} |
Oops, something went wrong.