CHE-1298; remove war name from url schema (#1572)
parent
58654dfcb1
commit
64ad23eda9
|
|
@ -29,7 +29,7 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
|
||||
public class DashboardRedirectionFilter implements Filter {
|
||||
private static Pattern projectPattern = Pattern.compile("^/ide/[^/]+?/.+");
|
||||
private static Pattern projectPattern = Pattern.compile("^/[^/]+?/.+");
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<title>Eclipse Che</title>
|
||||
<link rel="shortcut icon" href="/ide/_app/favicon.ico"/>
|
||||
<link rel="shortcut icon" href="/_app/favicon.ico"/>
|
||||
<link href="http://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet" type="text/css"/>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
};
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" language="javascript" src="/ide/_app/browserNotSupported.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="/ide/_app/_app.nocache.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="/_app/browserNotSupported.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="/_app/_app.nocache.js"></script>
|
||||
</head>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
|
||||
RewriteRule ^/api/(.*)$ /wsmaster/api/$1 [L]
|
||||
RewriteRule ^/$ /dashboard [R]
|
||||
|
|
@ -54,8 +54,8 @@ public class DashboardRedirectionFilterTest {
|
|||
public void shouldSkipRequestToProject() throws Exception {
|
||||
//given
|
||||
when(request.getMethod()).thenReturn("GET");
|
||||
when(request.getRequestURI()).thenReturn("/ide/namespace/ws-id/project1");
|
||||
when(request.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080/ide/namespace/ws-id/project1"));
|
||||
when(request.getRequestURI()).thenReturn("/namespace/ws-id/project1");
|
||||
when(request.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080/namespace/ws-id/project1"));
|
||||
EnvironmentContext context = new EnvironmentContext();
|
||||
context.setWorkspaceId("ws-id");
|
||||
EnvironmentContext.setCurrent(context);
|
||||
|
|
@ -88,8 +88,8 @@ public class DashboardRedirectionFilterTest {
|
|||
|
||||
@DataProvider(name = "nonNamespacePathProvider")
|
||||
public Object[][] nonProjectPathProvider() {
|
||||
return new Object[][]{{"/ws-id/", "http://localhost:8080/ide/ws-id123123/"},
|
||||
{"/wsname", "http://localhost:8080/ide/wsname_only"},
|
||||
return new Object[][]{{"/ws-id/", "http://localhost:8080/ws-id123123/"},
|
||||
{"/wsname", "http://localhost:8080/wsname_only"},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -97,8 +97,8 @@ public class DashboardRedirectionFilterTest {
|
|||
public void shouldSkipNotGETRequest(String method) throws Exception {
|
||||
//given
|
||||
when(request.getMethod()).thenReturn(method);
|
||||
when(request.getRequestURI()).thenReturn("/ide/ws-id/project1");
|
||||
when(request.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080/ide/ws-id/project1"));
|
||||
when(request.getRequestURI()).thenReturn("/ws-id/project1");
|
||||
when(request.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080/ws-id/project1"));
|
||||
EnvironmentContext context = new EnvironmentContext();
|
||||
context.setWorkspaceId("ws-id");
|
||||
EnvironmentContext.setCurrent(context);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<useProjectArtifact>false</useProjectArtifact>
|
||||
<unpack>false</unpack>
|
||||
<outputDirectory>tomcat/webapps</outputDirectory>
|
||||
<outputFileNameMapping>ide.war</outputFileNameMapping>
|
||||
<outputFileNameMapping>ROOT.war</outputFileNameMapping>
|
||||
<includes>
|
||||
<include>org.eclipse.che:assembly-ide-war</include>
|
||||
</includes>
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@ che.machine.projects.internal.storage=/projects
|
|||
# Che stores various internal data objects as JSON on the file system.
|
||||
che.conf.storage=${che.home}/storage
|
||||
|
||||
# The dashboard uses this to manage direction of requests to the IDE
|
||||
# Generally, do not modify.
|
||||
che.ide.context=ide
|
||||
|
||||
### Configuration of embedded templates and samples
|
||||
# Folder that contains JSON files with code templates and samples
|
||||
project.template_description.location_dir=${che.home}/templates
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ import org.eclipse.che.ide.collections.Jso;
|
|||
@Singleton
|
||||
public class BrowserQueryFieldRenderer {
|
||||
|
||||
private static final int WORKSPACE_ORDER_IN_URL = 3;
|
||||
private static final int NAMESPACE_ORDER_IN_URL = 2;
|
||||
private static final int WORKSPACE_ORDER_IN_URL = 2;
|
||||
private static final int NAMESPACE_ORDER_IN_URL = 1;
|
||||
//Used in the JSNI methods follow
|
||||
private static final int AMOUNT_URL_PARTS = 5;
|
||||
private static final int AMOUNT_URL_PARTS = 4;
|
||||
|
||||
//Used in the JSNI methods follow
|
||||
private final ProductInfoDataProvider productInfoDataProvider;
|
||||
|
|
@ -148,9 +148,9 @@ public class BrowserQueryFieldRenderer {
|
|||
var browserUrl = window.location.pathname;
|
||||
var urlParts = browserUrl.split('/');
|
||||
|
||||
urlParts[2] = namespace;
|
||||
urlParts[3] = workspaceName;
|
||||
urlParts[4] = projectName;
|
||||
urlParts[1] = namespace;
|
||||
urlParts[2] = workspaceName;
|
||||
urlParts[3] = projectName;
|
||||
|
||||
var sliceIndex = @org.eclipse.che.ide.context.BrowserQueryFieldRenderer::AMOUNT_URL_PARTS;
|
||||
if (namespace == null || namespace.length == 0) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.user.server;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
|
|
@ -22,9 +24,11 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static java.lang.String.format;
|
||||
|
|
@ -45,15 +49,17 @@ public class UserManager {
|
|||
private final UserDao userDao;
|
||||
private final UserProfileDao profileDao;
|
||||
private final PreferenceDao preferenceDao;
|
||||
|
||||
private final Set<String> reservedNames;
|
||||
|
||||
@Inject
|
||||
public UserManager(UserDao userDao,
|
||||
UserProfileDao profileDao,
|
||||
PreferenceDao preferenceDao) {
|
||||
PreferenceDao preferenceDao,
|
||||
@Named("user.reserved_names") String[] reservedNames) {
|
||||
this.userDao = userDao;
|
||||
this.profileDao = profileDao;
|
||||
this.preferenceDao = preferenceDao;
|
||||
this.reservedNames = Sets.newHashSet(reservedNames);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -68,6 +74,9 @@ public class UserManager {
|
|||
* when any other error occurs
|
||||
*/
|
||||
public void create(User user, boolean isTemporary) throws ConflictException, ServerException {
|
||||
if (reservedNames.contains(user.getName().toLowerCase())) {
|
||||
throw new ConflictException(String.format("Username \"%s\" is reserved", user.getName()));
|
||||
}
|
||||
user.withId(generate("user", ID_LENGTH))
|
||||
.withPassword(firstNonNull(user.getPassword(), generate("", PASSWORD_LENGTH)));
|
||||
userDao.create(user);
|
||||
|
|
|
|||
|
|
@ -10,15 +10,15 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.user.server;
|
||||
|
||||
import org.eclipse.che.api.core.BadRequestException;
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.user.server.dao.PreferenceDao;
|
||||
import org.eclipse.che.api.user.server.dao.Profile;
|
||||
import org.eclipse.che.api.user.server.dao.User;
|
||||
import org.eclipse.che.api.user.server.dao.UserDao;
|
||||
import org.eclipse.che.api.user.server.dao.UserProfileDao;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.testng.MockitoTestNGListener;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
|
@ -26,7 +26,6 @@ import static org.mockito.Matchers.any;
|
|||
import static org.mockito.Matchers.anyMapOf;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
|
|
@ -45,12 +44,17 @@ public class UserManagerTest {
|
|||
@Mock
|
||||
PreferenceDao preferenceDao;
|
||||
|
||||
@InjectMocks
|
||||
UserManager manager;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUp() {
|
||||
manager = new UserManager(userDao, profileDao, preferenceDao, new String[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateProfileAndPreferencesOnUserCreation() throws Exception {
|
||||
final User user = new User().withEmail("test@email.com").withName("testName");
|
||||
|
||||
manager.create(user, false);
|
||||
|
||||
verify(profileDao).create(any(Profile.class));
|
||||
|
|
@ -60,8 +64,16 @@ public class UserManagerTest {
|
|||
@Test
|
||||
public void shouldGeneratedPasswordWhenCreatingUserAndItIsMissing() throws Exception {
|
||||
final User user = new User().withEmail("test@email.com").withName("testName");
|
||||
|
||||
manager.create(user, false);
|
||||
|
||||
verify(userDao).create(eq(user.withPassword("<none>")));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ConflictException.class)
|
||||
public void shouldThrowConflictExceptionOnCreationIfUserNameIsReserved() throws Exception {
|
||||
final User user = new User().withEmail("test@email.com").withName("reserved");
|
||||
|
||||
new UserManager(userDao, profileDao, preferenceDao, new String[] {"reserved"}).create(user, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,13 +62,10 @@ public class WorkspaceServiceLinksInjector {
|
|||
|
||||
//TODO: we need keep IDE context in some property to have possibility configure it because context is different in Che and Hosted packaging
|
||||
//TODO: not good solution do it here but critical for this task https://jira.codenvycorp.com/browse/IDEX-3619
|
||||
private final String ideContext;
|
||||
private final MachineServiceLinksInjector machineLinksInjector;
|
||||
|
||||
@Inject
|
||||
public WorkspaceServiceLinksInjector(@Named("che.ide.context") String ideContext,
|
||||
MachineServiceLinksInjector machineLinksInjector) {
|
||||
this.ideContext = ideContext;
|
||||
public WorkspaceServiceLinksInjector(MachineServiceLinksInjector machineLinksInjector) {
|
||||
this.machineLinksInjector = machineLinksInjector;
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +110,7 @@ public class WorkspaceServiceLinksInjector {
|
|||
|
||||
//TODO here we add url to IDE with workspace name not good solution do it here but critical for this task https://jira.codenvycorp.com/browse/IDEX-3619
|
||||
final URI ideUri = uriBuilder.clone()
|
||||
.replacePath(ideContext)
|
||||
.replacePath("")
|
||||
.path(workspace.getNamespace())
|
||||
.path(workspace.getConfig().getName())
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ public class WorkspaceServiceTest {
|
|||
private static final ApiExceptionMapper MAPPER = new ApiExceptionMapper();
|
||||
private static final String NAMESPACE = "user";
|
||||
private static final String USER_ID = "user123";
|
||||
private static final String IDE_CONTEXT = "ws";
|
||||
@SuppressWarnings("unused")
|
||||
private static final EnvironmentFilter FILTER = new EnvironmentFilter();
|
||||
|
||||
|
|
@ -130,7 +129,7 @@ public class WorkspaceServiceTest {
|
|||
service = new WorkspaceService(wsManager,
|
||||
machineManager,
|
||||
validator,
|
||||
new WorkspaceServiceLinksInjector(IDE_CONTEXT, new MachineServiceLinksInjector()));
|
||||
new WorkspaceServiceLinksInjector(new MachineServiceLinksInjector()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue