Skip to content
Snippets Groups Projects
Commit 589b079b authored by Martin Staehr's avatar Martin Staehr
Browse files

fix: fix rocket.chat link and login test

parent f63eda30
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ public class GFRocketChatConfig { ...@@ -7,7 +7,7 @@ public class GFRocketChatConfig {
//private static final String ROCKET_CHAT_LINK = "http://rocketchat.westeurope.cloudapp.azure.com/"; //private static final String ROCKET_CHAT_LINK = "http://rocketchat.westeurope.cloudapp.azure.com/";
private static final String ROCKET_CHAT_LINK = "https://rocket.farm-test.rz.uni-potsdam.de/home/"; private static final String ROCKET_CHAT_LINK = "https://rocket.farm-test.rz.uni-potsdam.de/";
// or https://rocket.farm.uni-potsdam.de/ // or https://rocket.farm.uni-potsdam.de/
// https://rocket.farm-test.rz.uni-potsdam.de/home // https://rocket.farm-test.rz.uni-potsdam.de/home
......
...@@ -25,15 +25,28 @@ import javax.annotation.ManagedBean; ...@@ -25,15 +25,28 @@ import javax.annotation.ManagedBean;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.mail.*; import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static unipotsdam.gf.config.GFMailConfig.*; import static unipotsdam.gf.config.GFMailConfig.SMTP_HOST;
import static unipotsdam.gf.config.GFMailConfig.SMTP_PASSWORD;
import static unipotsdam.gf.config.GFMailConfig.SMTP_PORT;
import static unipotsdam.gf.config.GFMailConfig.SMTP_USERNAME;
import static unipotsdam.gf.config.GFRocketChatConfig.ADMIN_USER; import static unipotsdam.gf.config.GFRocketChatConfig.ADMIN_USER;
import static unipotsdam.gf.config.GFRocketChatConfig.ROCKET_CHAT_API_LINK; import static unipotsdam.gf.config.GFRocketChatConfig.ROCKET_CHAT_API_LINK;
import static unipotsdam.gf.config.GFRocketChatConfig.ROCKET_CHAT_ROOM_LINK; import static unipotsdam.gf.config.GFRocketChatConfig.ROCKET_CHAT_ROOM_LINK;
...@@ -249,14 +262,6 @@ public class CommunicationService implements ICommunication { ...@@ -249,14 +262,6 @@ public class CommunicationService implements ICommunication {
rocketChatAuth.put("user", user.getEmail()); rocketChatAuth.put("user", user.getEmail());
rocketChatAuth.put("password", user.getPassword()); rocketChatAuth.put("password", user.getPassword());
HttpResponse<String> response2 =
unirestService
.post(ROCKET_CHAT_API_LINK + "login")
.body(rocketChatAuth)
.asObject(String.class);
System.out.println(response2.getBody());
HttpResponse<RocketChatLoginResponse> response = HttpResponse<RocketChatLoginResponse> response =
unirestService unirestService
.post(ROCKET_CHAT_API_LINK + "login") .post(ROCKET_CHAT_API_LINK + "login")
...@@ -274,6 +279,7 @@ public class CommunicationService implements ICommunication { ...@@ -274,6 +279,7 @@ public class CommunicationService implements ICommunication {
RocketChatLoginResponse rocketChatLoginResponse = response.getBody(); RocketChatLoginResponse rocketChatLoginResponse = response.getBody();
user.setRocketChatUserId(rocketChatLoginResponse.getUserId()); user.setRocketChatUserId(rocketChatLoginResponse.getUserId());
user.setRocketChatAuthToken(rocketChatLoginResponse.getAuthToken()); user.setRocketChatAuthToken(rocketChatLoginResponse.getAuthToken());
return true; return true;
} }
......
...@@ -2,12 +2,13 @@ package unipotsdam.gf.modules.communication.service; ...@@ -2,12 +2,13 @@ package unipotsdam.gf.modules.communication.service;
import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.ServiceLocatorUtilities; import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
import org.junit.*; import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import uk.co.jemos.podam.api.PodamFactory; import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl; import uk.co.jemos.podam.api.PodamFactoryImpl;
import unipotsdam.gf.config.GFApplicationBinder; import unipotsdam.gf.config.GFApplicationBinder;
import unipotsdam.gf.core.database.InMemoryMySqlConnect;
import unipotsdam.gf.core.database.TestGFApplicationBinder;
import unipotsdam.gf.interfaces.ICommunication; import unipotsdam.gf.interfaces.ICommunication;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
import unipotsdam.gf.modules.communication.model.EMailMessage; import unipotsdam.gf.modules.communication.model.EMailMessage;
...@@ -19,18 +20,23 @@ import unipotsdam.gf.modules.project.ProjectDAO; ...@@ -19,18 +20,23 @@ import unipotsdam.gf.modules.project.ProjectDAO;
import unipotsdam.gf.modules.user.User; import unipotsdam.gf.modules.user.User;
import unipotsdam.gf.modules.user.UserDAO; import unipotsdam.gf.modules.user.UserDAO;
import unipotsdam.gf.modules.user.UserProfile; import unipotsdam.gf.modules.user.UserProfile;
import unipotsdam.gf.modules.user.UserView;
import unipotsdam.gf.mysql.MysqlConnect;
import unipotsdam.gf.process.constraints.Constraints; import unipotsdam.gf.process.constraints.Constraints;
import unipotsdam.gf.process.constraints.ConstraintsMessages; import unipotsdam.gf.process.constraints.ConstraintsMessages;
import javax.inject.Inject; import javax.inject.Inject;
import java.net.URISyntaxException; import java.util.ArrayList;
import java.util.*; import java.util.Arrays;
import java.util.Collections;
import static org.hamcrest.Matchers.is; import java.util.HashMap;
import static org.junit.Assert.*; import java.util.List;
import static unipotsdam.gf.config.GFRocketChatConfig.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static unipotsdam.gf.config.GFRocketChatConfig.ADMIN_USER;
import static unipotsdam.gf.config.GFRocketChatConfig.ROCKET_CHAT_ROOM_LINK;
import static unipotsdam.gf.config.GFRocketChatConfig.TEST_USER;
public class CommunicationServiceTest { public class CommunicationServiceTest {
...@@ -75,7 +81,7 @@ public class CommunicationServiceTest { ...@@ -75,7 +81,7 @@ public class CommunicationServiceTest {
public void loginUser() { public void loginUser() {
assertTrue(iCommunication.loginUser(TEST_USER)); assertTrue(iCommunication.loginUser(TEST_USER));
assertTrue(!TEST_USER.getRocketChatAuthToken().isEmpty()); assertTrue(!TEST_USER.getRocketChatAuthToken().isEmpty());
assertTrue(TEST_USER.getRocketChatUserId().isEmpty()); assertTrue(!TEST_USER.getRocketChatUserId().isEmpty());
User falseLoginUser = new User("name", "password", "email", true); User falseLoginUser = new User("name", "password", "email", true);
assertFalse(iCommunication.loginUser(falseLoginUser)); assertFalse(iCommunication.loginUser(falseLoginUser));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment