@Test public void testController() { LoginController controller = new LoginController(); Model model = new ExtendedModelMap(); Assert.assertEquals("home", controller.home(model)); Object message = model.asMap().get("controllerMessage"); Assert.assertEquals("This is the message from the controller!", message); }
@Test public void happyPath() { loginInfo.setUserId("junit"); loginInfo.setPassword("password"); String viewName = controller.onLogin(loginInfo, model); assertEquals("greetings", viewName); }
@Test public void when_no_name_entered_shows_error_message() throws Exception { ModelMap model = new ModelMap(); String viewName = controller.onLogin(new LoginInfo(), model); assertEquals("login", viewName); assertEquals("invalid login name", model.get("error")); }
@Override protected void login(LoginController controller, Credentials credentials) throws IOException { try { client = new CloudFrontService( new AWSCredentials(credentials.getUsername(), credentials.getPassword())) { @Override protected HttpClient initHttpConnection() { return CloudFrontDistributionConfiguration.this.http(); } }; // Provoke authentication error for (String container : this.getContainers()) { for (Distribution.Method method : getMethods(container)) { // Cache first container this.cache(this.getOrigin(method, container), method); break; } break; } } catch (CloudFrontServiceException e) { log.warn(String.format("Invalid account: %s", e.getMessage())); this.message(Locale.localizedString("Login failed", "Credentials")); controller.fail(host.getProtocol(), credentials); this.login(); } }
@Test public void when_invalid_password_entered_shows_error_message() { ModelMap model = new ModelMap(); LoginInfo loginInfo = new LoginInfo(); loginInfo.setUserId("junit"); String viewName = controller.onLogin(loginInfo, model); assertEquals("login", viewName); assertEquals("invalid password", model.get("error")); }
@Override protected void prompt(LoginController controller) throws LoginCanceledException { // Configure with the same host as S3 to get the same credentials from the keychain. controller.check( new Host(Protocol.S3_SSL, Protocol.S3_SSL.getDefaultHostname(), host.getCredentials()), this.getName(), null, true, false, false); }
private void initNifty() { flyCam.setDragToRotate(true); loginController = new LoginController(); loginController.initialize(app.getStateManager(), app); nifty.registerScreenController(loginController); loginScreenBuilder.buildLoginScreen(nifty, loginController); nifty .getScreen("LoginScreen") .findNiftyControl("PasswordTextField", TextField.class) .enablePasswordChar('*'); }
public void testLogin() { IMocksControl control = createControl(); RobinServiceAsync service = control.createMock(RobinServiceAsync.class); LoginController controller = new LoginController(service, null, null); String user = "******"; String password = "******"; LoginModel model = control.createMock(LoginModel.class); expect(model.getUser()).andReturn(user); expect(model.getPassword()).andReturn(password); service.logIn(user, password, controller.callback); control.replay(); controller.onLoginButtonClick(model); control.verify(); }
public void refreshTaskList() { tasks = new ArrayList<Task>(); // TODO use user instead. Problems with refresh after dealing with couple of users. final List<Task> all = taskService.loadForUserAndStatus(loginController.getUser(), displayCloseTasks); if (categoryFilter != null) { for (final Task task : all) { if (task.getCategory() == categoryFilter) { tasks.add(task); } } } else { tasks = all; } }
public void createLoginScreen() { Parent root = null; FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("/GraphicPack/clientLogin.fxml")); try { root = loader.load(); } catch (IOException e) { e.printStackTrace(); } loginStage = new Stage(); loginStage.setTitle("LOGIN to PUBBLICACOMUNICAZIONE"); // primaryStage.getIcons().add(new Image("/Images/server.png")); loginStage.setScene(new Scene(root, 255, 339)); loginController = loader.getController(); loginController.setClientMain(this); loginStage.show(); }
@RequestMapping(method = POST) public AuthenticatedUserPublic create( HttpServletRequest request, HttpServletResponse response, @RequestBody DomainUser user) { userService.create(user); return loginController.doLogin(request, response, user.getEmail(), user.getPassword()); }
public void generate() { taskService.generateTasks(loginController.getUser()); }
private void whenPostLoginPage() { actual = controller.postLogin(mockRequestContext); }
private void whenGetLoginPage() { actual = controller.getLoginPage(mockRequestContext); }
private void whenLogoutPage() { actual = controller.logout(mockRequestContext); }
@Override protected void login(LoginController controller) throws IOException { super.login(controller); controller.success( new Host(Protocol.S3_SSL, Protocol.S3_SSL.getDefaultHostname(), host.getCredentials())); }