Search in sources :

Example 6 with IRuntimeManager

use of com.gitblit.manager.IRuntimeManager in project gitblit by gitblit.

the class BranchTicketServiceTest method getService.

@Override
protected ITicketService getService(boolean deleteAll) throws Exception {
    IStoredSettings settings = getSettings(deleteAll);
    XssFilter xssFilter = new AllowXssFilter();
    IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter).start();
    IPluginManager pluginManager = new PluginManager(runtimeManager).start();
    INotificationManager notificationManager = new NotificationManager(settings).start();
    IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
    IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, pluginManager, userManager).start();
    BranchTicketService service = (BranchTicketService) new BranchTicketService(runtimeManager, pluginManager, notificationManager, userManager, repositoryManager).start();
    if (deleteAll) {
        service.deleteAll(getRepository());
    }
    return service;
}
Also used : BranchTicketService(com.gitblit.tickets.BranchTicketService) NotificationManager(com.gitblit.manager.NotificationManager) INotificationManager(com.gitblit.manager.INotificationManager) IUserManager(com.gitblit.manager.IUserManager) IStoredSettings(com.gitblit.IStoredSettings) IRuntimeManager(com.gitblit.manager.IRuntimeManager) RuntimeManager(com.gitblit.manager.RuntimeManager) IRepositoryManager(com.gitblit.manager.IRepositoryManager) IRuntimeManager(com.gitblit.manager.IRuntimeManager) IPluginManager(com.gitblit.manager.IPluginManager) PluginManager(com.gitblit.manager.PluginManager) INotificationManager(com.gitblit.manager.INotificationManager) IUserManager(com.gitblit.manager.IUserManager) UserManager(com.gitblit.manager.UserManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) IPluginManager(com.gitblit.manager.IPluginManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) IRepositoryManager(com.gitblit.manager.IRepositoryManager) RepositoryManager(com.gitblit.manager.RepositoryManager)

Example 7 with IRuntimeManager

use of com.gitblit.manager.IRuntimeManager in project gitblit by gitblit.

the class FileTicketServiceTest method getService.

@Override
protected ITicketService getService(boolean deleteAll) throws Exception {
    IStoredSettings settings = getSettings(deleteAll);
    XssFilter xssFilter = new AllowXssFilter();
    IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter).start();
    IPluginManager pluginManager = new PluginManager(runtimeManager).start();
    INotificationManager notificationManager = new NotificationManager(settings).start();
    IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
    IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, pluginManager, userManager).start();
    FileTicketService service = (FileTicketService) new FileTicketService(runtimeManager, pluginManager, notificationManager, userManager, repositoryManager).start();
    if (deleteAll) {
        service.deleteAll(getRepository());
    }
    return service;
}
Also used : NotificationManager(com.gitblit.manager.NotificationManager) INotificationManager(com.gitblit.manager.INotificationManager) IUserManager(com.gitblit.manager.IUserManager) IStoredSettings(com.gitblit.IStoredSettings) IRuntimeManager(com.gitblit.manager.IRuntimeManager) RuntimeManager(com.gitblit.manager.RuntimeManager) IRepositoryManager(com.gitblit.manager.IRepositoryManager) IRuntimeManager(com.gitblit.manager.IRuntimeManager) IPluginManager(com.gitblit.manager.IPluginManager) PluginManager(com.gitblit.manager.PluginManager) INotificationManager(com.gitblit.manager.INotificationManager) IUserManager(com.gitblit.manager.IUserManager) UserManager(com.gitblit.manager.UserManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) FileTicketService(com.gitblit.tickets.FileTicketService) IPluginManager(com.gitblit.manager.IPluginManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) IRepositoryManager(com.gitblit.manager.IRepositoryManager) RepositoryManager(com.gitblit.manager.RepositoryManager)

Example 8 with IRuntimeManager

use of com.gitblit.manager.IRuntimeManager in project gitblit by gitblit.

the class AuthenticationManagerTest method newAuthenticationManager.

IAuthenticationManager newAuthenticationManager() {
    XssFilter xssFilter = new AllowXssFilter();
    RuntimeManager runtime = new RuntimeManager(getSettings(), xssFilter, GitBlitSuite.BASEFOLDER).start();
    users = new UserManager(runtime, null).start();
    final Map<String, UserModel> virtualUsers = new HashMap<String, UserModel>();
    users.setUserService(new IUserService() {

        @Override
        public void setup(IRuntimeManager runtimeManager) {
        }

        @Override
        public String getCookie(UserModel model) {
            return null;
        }

        @Override
        public UserModel getUserModel(char[] cookie) {
            return null;
        }

        @Override
        public UserModel getUserModel(String username) {
            return virtualUsers.get(username);
        }

        @Override
        public boolean updateUserModel(UserModel model) {
            virtualUsers.put(model.username, model);
            return true;
        }

        @Override
        public boolean updateUserModels(Collection<UserModel> models) {
            return false;
        }

        @Override
        public boolean updateUserModel(String username, UserModel model) {
            virtualUsers.put(username, model);
            return true;
        }

        @Override
        public boolean deleteUserModel(UserModel model) {
            return false;
        }

        @Override
        public boolean deleteUser(String username) {
            return false;
        }

        @Override
        public List<String> getAllUsernames() {
            return null;
        }

        @Override
        public List<UserModel> getAllUsers() {
            return null;
        }

        @Override
        public List<String> getAllTeamNames() {
            return null;
        }

        @Override
        public List<TeamModel> getAllTeams() {
            return null;
        }

        @Override
        public List<String> getTeamNamesForRepositoryRole(String role) {
            return null;
        }

        @Override
        public TeamModel getTeamModel(String teamname) {
            return null;
        }

        @Override
        public boolean updateTeamModel(TeamModel model) {
            return false;
        }

        @Override
        public boolean updateTeamModels(Collection<TeamModel> models) {
            return false;
        }

        @Override
        public boolean updateTeamModel(String teamname, TeamModel model) {
            return false;
        }

        @Override
        public boolean deleteTeamModel(TeamModel model) {
            return false;
        }

        @Override
        public boolean deleteTeam(String teamname) {
            return false;
        }

        @Override
        public List<String> getUsernamesForRepositoryRole(String role) {
            return null;
        }

        @Override
        public boolean renameRepositoryRole(String oldRole, String newRole) {
            return false;
        }

        @Override
        public boolean deleteRepositoryRole(String role) {
            return false;
        }
    });
    AuthenticationManager auth = new AuthenticationManager(runtime, users).start();
    return auth;
}
Also used : HashMap(java.util.HashMap) IRuntimeManager(com.gitblit.manager.IRuntimeManager) RuntimeManager(com.gitblit.manager.RuntimeManager) UserModel(com.gitblit.models.UserModel) IRuntimeManager(com.gitblit.manager.IRuntimeManager) AuthenticationManager(com.gitblit.manager.AuthenticationManager) IAuthenticationManager(com.gitblit.manager.IAuthenticationManager) TeamModel(com.gitblit.models.TeamModel) UserManager(com.gitblit.manager.UserManager) IUserService(com.gitblit.IUserService) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) List(java.util.List)

Example 9 with IRuntimeManager

use of com.gitblit.manager.IRuntimeManager in project gitblit by gitblit.

the class SshKerberosAuthenticationTest method testUserManager.

@Test
public void testUserManager() {
    IRuntimeManager rm = Mockito.mock(IRuntimeManager.class);
    //Build an UserManager that can build a UserModel
    IUserManager im = Mockito.mock(IUserManager.class);
    Mockito.doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            String user = (String) args[0];
            return new UserModel(user);
        }
    }).when(im).getUserModel(Mockito.anyString());
    AuthenticationManager am = new AuthenticationManager(rm, im);
    GSSAuthenticator gssAuthenticator = new SshKrbAuthenticator(new MemorySettings(), am);
    ServerSession session = Mockito.mock(ServerSession.class);
    //Build an SshDaemonClient that can set and get the UserModel
    final UserModelWrapper umw = new UserModelWrapper();
    SshDaemonClient client = Mockito.mock(SshDaemonClient.class);
    Mockito.when(client.getUser()).thenReturn(umw.um);
    Mockito.doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            UserModel um = (UserModel) args[0];
            umw.um = um;
            return null;
        }
    }).when(client).setUser(Mockito.any(UserModel.class));
    Mockito.when(session.getAttribute(SshDaemonClient.KEY)).thenReturn(client);
    Assert.assertTrue(gssAuthenticator.validateIdentity(session, "jhappy"));
}
Also used : GSSAuthenticator(org.apache.sshd.server.auth.gss.GSSAuthenticator) ServerSession(org.apache.sshd.server.session.ServerSession) IUserManager(com.gitblit.manager.IUserManager) SshDaemonClient(com.gitblit.transport.ssh.SshDaemonClient) SshKrbAuthenticator(com.gitblit.transport.ssh.SshKrbAuthenticator) IRuntimeManager(com.gitblit.manager.IRuntimeManager) UserModel(com.gitblit.models.UserModel) AuthenticationManager(com.gitblit.manager.AuthenticationManager) InvocationOnMock(org.mockito.invocation.InvocationOnMock) MemorySettings(com.gitblit.tests.mock.MemorySettings) Test(org.junit.Test)

Aggregations

IRuntimeManager (com.gitblit.manager.IRuntimeManager)9 RuntimeManager (com.gitblit.manager.RuntimeManager)7 XssFilter (com.gitblit.utils.XssFilter)7 AllowXssFilter (com.gitblit.utils.XssFilter.AllowXssFilter)7 IRepositoryManager (com.gitblit.manager.IRepositoryManager)6 RepositoryManager (com.gitblit.manager.RepositoryManager)6 IStoredSettings (com.gitblit.IStoredSettings)5 IPluginManager (com.gitblit.manager.IPluginManager)5 IUserManager (com.gitblit.manager.IUserManager)5 UserManager (com.gitblit.manager.UserManager)5 INotificationManager (com.gitblit.manager.INotificationManager)4 NotificationManager (com.gitblit.manager.NotificationManager)4 PluginManager (com.gitblit.manager.PluginManager)4 BranchTicketService (com.gitblit.tickets.BranchTicketService)4 AuthenticationManager (com.gitblit.manager.AuthenticationManager)2 UserModel (com.gitblit.models.UserModel)2 FileTicketService (com.gitblit.tickets.FileTicketService)2 ITicketService (com.gitblit.tickets.ITicketService)2 RedisTicketService (com.gitblit.tickets.RedisTicketService)2 CmdLineException (org.kohsuke.args4j.CmdLineException)2