-
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
71 changed files
with
425 additions
and
327 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
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
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; | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/dashboard-frontend/src/services/backend-client/oAuthApi.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,34 @@ | ||
/* | ||
* 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'; | ||
import { api } from '@eclipse-che/common'; | ||
import { IGitOauth } from '../../store/GitOauthConfig/types'; | ||
|
||
export async function getOAuthProviders(): Promise<IGitOauth[]> { | ||
const response = await axios.get(`${cheServerPrefix}/oauth`); | ||
|
||
return response.data; | ||
} | ||
|
||
export async function getOAuthToken(provider: api.GitOauthProvider): Promise<{ token: string }> { | ||
const response = await axios.get(`${cheServerPrefix}/oauth/token?oauth_provider=${provider}`); | ||
|
||
return response.data; | ||
} | ||
|
||
export async function deleteOAuthToken(provider: api.GitOauthProvider): Promise<void> { | ||
await axios.delete(`${cheServerPrefix}/oauth/token?oauth_provider=${provider}`); | ||
|
||
return Promise.resolve(); | ||
} |
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.
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
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
Oops, something went wrong.