diff --git a/packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/__tests__/index.spec.tsx b/packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/__tests__/index.spec.tsx
index bf4fdc4d2..772e6da4c 100644
--- a/packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/__tests__/index.spec.tsx
+++ b/packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/__tests__/index.spec.tsx
@@ -694,6 +694,32 @@ describe('Creating steps, fetching a devfile', () => {
const host = 'che-host';
const protocol = 'http://';
const factoryUrl = 'git@github.com:user/repository-name.git';
+ const emptyStore = new MockStoreBuilder().build();
+ const sshPrivateRepoAllertItem = expect.objectContaining({
+ title: 'Warning',
+ variant: AlertVariant.warning,
+ children: (
+
+ ),
+ actionCallbacks: [
+ expect.objectContaining({
+ title: 'Continue with default devfile',
+ callback: expect.any(Function),
+ }),
+ expect.objectContaining({
+ title: 'Reload',
+ callback: expect.any(Function),
+ }),
+ expect.objectContaining({
+ title: 'Open Documentation page',
+ callback: expect.any(Function),
+ }),
+ ],
+ });
let spyWindowLocation: jest.SpyInstance;
let location: Location;
@@ -746,43 +772,31 @@ describe('Creating steps, fetching a devfile', () => {
});
it('should show warning on SSH url', async () => {
- const expectAlertItem = expect.objectContaining({
- title: 'Warning',
- variant: AlertVariant.warning,
- children: (
-
- ),
- actionCallbacks: [
- expect.objectContaining({
- title: 'Continue with default devfile',
- callback: expect.any(Function),
- }),
- expect.objectContaining({
- title: 'Reload',
- callback: expect.any(Function),
- }),
- expect.objectContaining({
- title: 'Open Documentation page',
- callback: expect.any(Function),
- }),
- ],
- });
searchParams = new URLSearchParams({
[FACTORY_URL_ATTR]: 'git@github.com:user/repository.git',
});
- const emptyStore = new MockStoreBuilder().build();
+
renderComponent(emptyStore, searchParams, location);
await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS);
+ await waitFor(() => expect(mockOnNextStep).not.toHaveBeenCalled);
+
+ expect(mockOpenOAuthPage).not.toHaveBeenCalled();
+ expect(mockOnError).toHaveBeenCalledWith(sshPrivateRepoAllertItem);
+ });
+
+ it('should show warning on bitbucket-server SSH url', async () => {
+ searchParams = new URLSearchParams({
+ [FACTORY_URL_ATTR]: 'ssh://git@bitbucket-server.com/~user/repository.git',
+ });
+
+ renderComponent(emptyStore, searchParams, location);
+ await jest.advanceTimersByTimeAsync(MIN_STEP_DURATION_MS);
await waitFor(() => expect(mockOnNextStep).not.toHaveBeenCalled);
expect(mockOpenOAuthPage).not.toHaveBeenCalled();
- expect(mockOnError).toHaveBeenCalledWith(expectAlertItem);
+ expect(mockOnError).toHaveBeenCalledWith(sshPrivateRepoAllertItem);
});
});
});
diff --git a/packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/index.tsx b/packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/index.tsx
index 08317b62d..e61138f67 100644
--- a/packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/index.tsx
+++ b/packages/dashboard-frontend/src/components/WorkspaceProgress/CreatingSteps/Fetch/Devfile/index.tsx
@@ -77,6 +77,7 @@ export type State = ProgressStepState & {
class CreatingStepFetchDevfile extends ProgressStep {
protected readonly name = 'Inspecting repo';
+ private readonly sshPattern = new RegExp('(git@|(ssh|git)://).*');
constructor(props: Props) {
super(props);
@@ -232,7 +233,8 @@ class CreatingStepFetchDevfile extends ProgressStep {
errorMessage === 'Failed to fetch devfile' ||
errorMessage.startsWith('Could not reach devfile')
) {
- if (sourceUrl.startsWith('git@')) {
+ // check if the source url is an SSH url
+ if (this.sshPattern.test(sourceUrl)) {
throw new SSHPrivateRepositoryUrlError(errorMessage);
} else {
throw new UnsupportedGitProviderError(errorMessage);