Search in sources :

Example 1 with GitlabManagerRestricted

use of de.catma.repository.git.managers.GitlabManagerRestricted in project catma by forTEXT.

the class GitProjectHandlerTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    // create a fake CATMA user which we'll use to instantiate GitlabManagerRestricted (using the corresponding impersonation token) & JGitRepoManager
    Integer randomUserId = Integer.parseInt(RandomStringUtils.randomNumeric(3));
    String username = String.format("testuser-%s", randomUserId);
    String email = String.format("%s@catma.de", username);
    String name = String.format("Test User %s", randomUserId);
    gitlabManagerPrivileged = new GitlabManagerPrivileged();
    String impersonationToken = gitlabManagerPrivileged.acquireImpersonationToken(username, "catma", email, name).getSecond();
    EventBus mockEventBus = mock(EventBus.class);
    BackgroundService mockBackgroundService = mock(BackgroundService.class);
    gitlabManagerRestricted = new GitlabManagerRestricted(mockEventBus, mockBackgroundService, impersonationToken);
}
Also used : BackgroundService(de.catma.backgroundservice.BackgroundService) GitlabManagerPrivileged(de.catma.repository.git.managers.GitlabManagerPrivileged) GitlabManagerRestricted(de.catma.repository.git.managers.GitlabManagerRestricted) EventBus(com.google.common.eventbus.EventBus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with GitlabManagerRestricted

use of de.catma.repository.git.managers.GitlabManagerRestricted in project catma by forTEXT.

the class GitSourceDocumentHandlerTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    // create a fake CATMA user which we'll use to instantiate GitlabManagerRestricted (using the corresponding impersonation token) & JGitRepoManager
    Integer randomUserId = Integer.parseInt(RandomStringUtils.randomNumeric(3));
    String username = String.format("testuser-%s", randomUserId);
    String email = String.format("%s@catma.de", username);
    String name = String.format("Test User %s", randomUserId);
    gitlabManagerPrivileged = new GitlabManagerPrivileged();
    String impersonationToken = gitlabManagerPrivileged.acquireImpersonationToken(username, "catma", email, name).getSecond();
    EventBus mockEventBus = mock(EventBus.class);
    BackgroundService mockBackgroundService = mock(BackgroundService.class);
    gitlabManagerRestricted = new GitlabManagerRestricted(mockEventBus, mockBackgroundService, impersonationToken);
}
Also used : BackgroundService(de.catma.backgroundservice.BackgroundService) GitlabManagerPrivileged(de.catma.repository.git.managers.GitlabManagerPrivileged) GitlabManagerRestricted(de.catma.repository.git.managers.GitlabManagerRestricted) EventBus(com.google.common.eventbus.EventBus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with GitlabManagerRestricted

use of de.catma.repository.git.managers.GitlabManagerRestricted in project catma by forTEXT.

the class CatmaApplication method init.

@Override
protected void init(VaadinRequest request) {
    eventBus = new EventBus();
    initService = new Vaadin8InitializationService();
    loginservice = new GitlabLoginService(new IRemoteGitManagerFactory() {

        @Override
        public IRemoteGitManagerRestricted createFromUsernameAndPassword(String username, String password) throws IOException {
            return new GitlabManagerRestricted(eventBus, initService.acquireBackgroundService(), username, password);
        }

        @Override
        public IRemoteGitManagerRestricted createFromImpersonationToken(String userImpersonationToken) throws IOException {
            return new GitlabManagerRestricted(eventBus, initService.acquireBackgroundService(), userImpersonationToken);
        }
    });
    hazelCastService = new HazelCastService();
    this.eventBus.register(this);
    try {
        sqliteService = new SqliteService();
    } catch (Exception e) {
        showAndLogError("error initialising sqlite service", e);
    }
    logger.info("Session: " + request.getWrappedSession().getId());
    storeParameters(request.getParameterMap());
    Page.getCurrent().setTitle("CATMA " + Version.LATEST);
    try {
        Component component = initService.newEntryPage(eventBus, loginservice, hazelCastService, sqliteService);
        setContent(component);
    } catch (IOException e) {
        showAndLogError("error creating landing page", e);
    }
    eventBus.post(new RouteToDashboardEvent());
    // A fresh UI and session doesn't have a request handler registered yet.
    // we need to verify tokens here too.
    handleRequestToken(request);
    handleRequestOauth(request);
}
Also used : IRemoteGitManagerFactory(de.catma.ui.di.IRemoteGitManagerFactory) Vaadin8InitializationService(de.catma.ui.login.Vaadin8InitializationService) GitlabManagerRestricted(de.catma.repository.git.managers.GitlabManagerRestricted) GitlabLoginService(de.catma.ui.login.GitlabLoginService) EventBus(com.google.common.eventbus.EventBus) IOException(java.io.IOException) SqliteService(de.catma.sqlite.SqliteService) Component(com.vaadin.ui.Component) RouteToDashboardEvent(de.catma.ui.events.routing.RouteToDashboardEvent) HazelCastService(de.catma.hazelcast.HazelCastService) IOException(java.io.IOException)

Aggregations

EventBus (com.google.common.eventbus.EventBus)3 GitlabManagerRestricted (de.catma.repository.git.managers.GitlabManagerRestricted)3 BackgroundService (de.catma.backgroundservice.BackgroundService)2 GitlabManagerPrivileged (de.catma.repository.git.managers.GitlabManagerPrivileged)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Component (com.vaadin.ui.Component)1 HazelCastService (de.catma.hazelcast.HazelCastService)1 SqliteService (de.catma.sqlite.SqliteService)1 IRemoteGitManagerFactory (de.catma.ui.di.IRemoteGitManagerFactory)1 RouteToDashboardEvent (de.catma.ui.events.routing.RouteToDashboardEvent)1 GitlabLoginService (de.catma.ui.login.GitlabLoginService)1 Vaadin8InitializationService (de.catma.ui.login.Vaadin8InitializationService)1 IOException (java.io.IOException)1