use of com.gitblit.manager.AuthenticationManager in project gitblit by gitblit.
the class RedmineAuthenticationTest method testAuthenticationManager.
@Test
public void testAuthenticationManager() throws Exception {
AuthenticationManager auth = newAuthenticationManager();
UserModel userModel = auth.authenticate("RedmineAdminId", "RedmineAPIKey".toCharArray(), null);
assertThat(userModel.getName(), is("redmineadminid"));
assertThat(userModel.getDisplayName(), is("baz foo"));
assertThat(userModel.emailAddress, is("baz@example.com"));
assertNotNull(userModel.cookie);
}
use of com.gitblit.manager.AuthenticationManager in project gitblit by gitblit.
the class HtpasswdAuthenticationTest method newAuthenticationManager.
private AuthenticationManager newAuthenticationManager(IStoredSettings settings) {
XssFilter xssFilter = new AllowXssFilter();
RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();
UserManager users = new UserManager(runtime, null).start();
HtpasswdAuthProvider htpasswd = new HtpasswdAuthProvider();
htpasswd.setup(runtime, users);
AuthenticationManager auth = new AuthenticationManager(runtime, users);
auth.addAuthenticationProvider(htpasswd);
return auth;
}
use of com.gitblit.manager.AuthenticationManager in project gitblit by gitblit.
the class LdapAuthenticationTest method newAuthenticationManager.
private AuthenticationManager newAuthenticationManager(IStoredSettings settings) {
XssFilter xssFilter = new AllowXssFilter();
RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();
AuthenticationManager auth = new AuthenticationManager(runtime, userManager);
auth.addAuthenticationProvider(newLdapAuthentication(settings));
return auth;
}
use of com.gitblit.manager.AuthenticationManager 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;
}
use of com.gitblit.manager.AuthenticationManager 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"));
}
Aggregations