Throw the API exception with authorization URL on SCMunauthorised error (#621)
Fixes a bug with broken oauth flow caused by https://github.com/eclipse-che/che-server/pull/615pull/624/head
parent
7fe2a4dd3f
commit
ebca10356e
|
|
@ -30,6 +30,7 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
import org.eclipse.che.api.core.ApiException;
|
||||
import org.eclipse.che.api.core.BadRequestException;
|
||||
import org.eclipse.che.api.factory.server.scm.exception.ScmUnauthorizedException;
|
||||
import org.eclipse.che.api.factory.server.urlfactory.RemoteFactoryUrl.DevfileLocation;
|
||||
import org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto;
|
||||
import org.eclipse.che.api.factory.shared.dto.FactoryDto;
|
||||
|
|
@ -131,7 +132,9 @@ public class URLFactoryBuilder {
|
|||
continue;
|
||||
} catch (DevfileException e) {
|
||||
LOG.debug("Unexpected devfile exception: {}", e.getMessage());
|
||||
throw new ApiException(e.getMessage());
|
||||
throw e.getCause() instanceof ScmUnauthorizedException
|
||||
? toApiException(e, location)
|
||||
: new ApiException(e.getMessage());
|
||||
}
|
||||
if (isNullOrEmpty(devfileYamlContent)) {
|
||||
return Optional.empty();
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ public class URLFactoryBuilderTest {
|
|||
} catch (ApiException e) {
|
||||
assertTrue(e.getClass().isAssignableFrom(expectedClass));
|
||||
assertEquals(e.getMessage(), expectedMessage);
|
||||
if (e.getServiceError() instanceof ExtendedError)
|
||||
if ("SCM Authentication required".equals(e.getMessage()))
|
||||
assertEquals(((ExtendedError) e.getServiceError()).getAttributes(), expectedAttributes);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue