This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new 302c122 [OPENMEETINGS-2177] couple of tests are fixed
302c122 is described below
commit 302c122ba5a73d2afee6e453a8477a7427545674
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Tue Mar 3 00:44:25 2020 +0700
[OPENMEETINGS-2177] couple of tests are fixed
---
.../db/bind/adapter/OauthMapAdapter.java | 68 ++++++++++++++++------
.../org/apache/openmeetings/backup/TestImport.java | 2 +-
.../openmeetings/webservice/UserWebService.java | 42 ++++++-------
3 files changed, 72 insertions(+), 40 deletions(-)
diff --git
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/bind/adapter/OauthMapAdapter.java
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/bind/adapter/OauthMapAdapter.java
index 40dde6a..479bf2c 100644
---
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/bind/adapter/OauthMapAdapter.java
+++
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/bind/adapter/OauthMapAdapter.java
@@ -62,28 +62,60 @@ public class OauthMapAdapter extends XmlAdapter<Object,
Map<String, String>> {
}
}
- @Override
- public Map<String, String> unmarshal(Object v) throws Exception {
+ private static Map<String, String> getMap(String key, String value) {
Map<String, String> map = new HashMap<>();
- Element el = (Element)v;
- if ("loginParamName".equals(el.getLocalName())) {
- putValue(map, OAuthUser.PARAM_LOGIN,
el.getTextContent());
- } else if ("emailParamName".equals(el.getLocalName())) {
- putValue(map, OAuthUser.PARAM_EMAIL,
el.getTextContent());
- } else if ("firstnameParamName".equals(el.getLocalName())) {
- putValue(map, OAuthUser.PARAM_FNAME,
el.getTextContent());
- } else if ("lastnameParamName".equals(el.getLocalName())) {
- putValue(map, OAuthUser.PARAM_LNAME,
el.getTextContent());
- } else if ("mapping".equals(el.getLocalName())) {
- NodeList entries = el.getChildNodes();
- for (int i = 0; i < entries.getLength(); ++i) {
- Node entry = entries.item(i);
- NodeList children = entry.getChildNodes();
- if ("entry".equals(entry.getLocalName()) &&
children.getLength() == 2) {
- putValue(map,
children.item(0).getTextContent(), children.item(1).getTextContent());
+ putValue(map, key, value);
+ return map;
+ }
+
+ private static Map<String, String> getMap(NodeList entries) {
+ Map<String, String> map = new HashMap<>();
+ for (int i = 0; i < entries.getLength(); ++i) {
+ Node entry = entries.item(i);
+ NodeList children = entry.getChildNodes();
+ if ("entry".equals(entry.getLocalName()) &&
children.getLength() > 1) {
+ Node key = null;
+ Node value = null;
+ for (int j = 0; j < children.getLength(); ++j) {
+ Node n = children.item(j);
+ if (n.getNodeType() == Node.TEXT_NODE) {
+ continue;
+ }
+ if (key == null) {
+ key = n;
+ continue;
+ }
+ if (value == null) {
+ value = n;
+ break;
+ }
+ }
+ if (key != null && value != null) {
+ putValue(map, key.getTextContent(),
value.getTextContent());
}
}
}
return map;
}
+
+ @Override
+ public Map<String, String> unmarshal(Object v) throws Exception {
+ Element el = (Element)v;
+ if ("loginParamName".equals(el.getLocalName())) {
+ return getMap(OAuthUser.PARAM_LOGIN,
el.getTextContent());
+ }
+ if ("emailParamName".equals(el.getLocalName())) {
+ return getMap(OAuthUser.PARAM_EMAIL,
el.getTextContent());
+ }
+ if ("firstnameParamName".equals(el.getLocalName())) {
+ return getMap(OAuthUser.PARAM_FNAME,
el.getTextContent());
+ }
+ if ("lastnameParamName".equals(el.getLocalName())) {
+ return getMap(OAuthUser.PARAM_LNAME,
el.getTextContent());
+ }
+ if ("mapping".equals(el.getLocalName())) {
+ return getMap(el.getChildNodes());
+ }
+ return new HashMap<>();
+ }
}
diff --git
a/openmeetings-web/src/test/java/org/apache/openmeetings/backup/TestImport.java
b/openmeetings-web/src/test/java/org/apache/openmeetings/backup/TestImport.java
index 45c5f9a..203189b 100644
---
a/openmeetings-web/src/test/java/org/apache/openmeetings/backup/TestImport.java
+++
b/openmeetings-web/src/test/java/org/apache/openmeetings/backup/TestImport.java
@@ -67,7 +67,7 @@ public class TestImport extends AbstractTestImport {
cfgDao.update(def, null);
}
long ldapCount = ldapDao.count();
- File ldaps = new
File(getClass().getClassLoader().getResource("org/apache/openmeetings/backup/LDAP/ldapconfigs.xml").toURI());
+ File ldaps = new
File(getClass().getClassLoader().getResource("org/apache/openmeetings/backup/ldap/ldapconfigs.xml").toURI());
Long id = backupImport.importLdap(ldaps.getParentFile());
assertEquals(ldapCount + 1, ldapDao.count(), "Ldap should be
added");
LdapConfig ldap = ldapDao.get(id);
diff --git
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
index bee961b..3f9f4bc 100644
---
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
+++
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
@@ -82,7 +82,7 @@ import org.springframework.stereotype.Service;
@WebService(serviceName = USER_SERVICE_NAME, targetNamespace = TNS, portName =
USER_SERVICE_PORT_NAME)
@Features(features = "org.apache.cxf.ext.logging.LoggingFeature")
@Produces({MediaType.APPLICATION_JSON})
-@Path("/USER")
+@Path("/user")
public class UserWebService extends BaseWebService {
private static final Logger log =
LoggerFactory.getLogger(UserWebService.class);
@@ -94,7 +94,7 @@ public class UserWebService extends BaseWebService {
private GroupDao groupDao;
/**
- * @param USER - login or email of Openmeetings USER with admin or
SOAP-rights
+ * @param user - login or email of Openmeetings user with admin or
SOAP-rights
* @param pass - password
*
* @return - {@link ServiceResult} with error code or SID and userId
@@ -102,16 +102,16 @@ public class UserWebService extends BaseWebService {
@WebMethod
@GET
@Path("/login")
- public ServiceResult login(@WebParam(name="USER") @QueryParam("USER")
String user, @WebParam(name="pass") @QueryParam("pass") String pass) {
+ public ServiceResult login(@WebParam(name="user") @QueryParam("user")
String user, @WebParam(name="pass") @QueryParam("pass") String pass) {
try {
- log.debug("LOGIN USER");
+ log.debug("Login user");
User u = userDao.login(user, pass);
if (u == null) {
return new
ServiceResult("error.bad.credentials", Type.ERROR);
}
Sessiondata sd = sessionDao.create(u.getId(),
u.getLanguageId());
- log.debug("LOGIN USER: {}", u.getId());
+ log.debug("Login user: {}", u.getId());
return new ServiceResult(sd.getSessionId(),
Type.SUCCESS);
} catch (OmException oe) {
return oe.getKey() == null ? UNKNOWN : new
ServiceResult(oe.getKey(), Type.ERROR);
@@ -142,25 +142,25 @@ public class UserWebService extends BaseWebService {
*
* @param sid
* The SID from getSession
- * @param USER
- * USER object
+ * @param user
+ * user object
* @param confirm
* whatever or not to send email, leave empty for auto-send
*
- * @return - id of the USER added or error code
+ * @return - id of the user added or error code
*/
@WebMethod
@POST
@Path("/")
public UserDTO add(
@WebParam(name="sid") @QueryParam("sid") String sid
- , @WebParam(name="USER") @FormParam("USER") UserDTO user
+ , @WebParam(name="user") @FormParam("user") UserDTO user
, @WebParam(name="confirm") @FormParam("confirm")
Boolean confirm
)
{
return performCall(sid, User.Right.SOAP, sd -> {
if (!isAllowRegisterSoap()) {
- throw new ServiceException("SOAP register is
denied in Settings");
+ throw new ServiceException("Soap register is
denied in Settings");
}
User testUser =
userDao.getExternalUser(user.getExternalId(), user.getExternalType());
@@ -196,7 +196,7 @@ public class UserWebService extends BaseWebService {
jsonUser.addGroup(groupDao.get(getDefaultGroup()));
ouser = userManager.registerUser(jsonUser,
user.getPassword(), null);
} catch (NoSuchAlgorithmException | OmException e) {
- throw new ServiceException("Unexpected error
while creating USER");
+ throw new ServiceException("Unexpected error
while creating user");
}
if (ouser == null) {
@@ -222,14 +222,14 @@ public class UserWebService extends BaseWebService {
/**
*
- * Delete a certain USER by its id
+ * Delete a certain user by its id
*
* @param sid
* The SID from getSession
* @param id
- * the openmeetings USER id
+ * the openmeetings user id
*
- * @return - id of the USER deleted, error code otherwise
+ * @return - id of the user deleted, error code otherwise
*/
@WebMethod
@DELETE
@@ -244,7 +244,7 @@ public class UserWebService extends BaseWebService {
/**
*
- * Delete a certain USER by its external USER id
+ * Delete a certain user by its external user id
*
* @param sid
* The SID from getSession
@@ -253,7 +253,7 @@ public class UserWebService extends BaseWebService {
* @param externalType
* externalUserId
*
- * @return - id of USER deleted, or error code
+ * @return - id of user deleted, or error code
*/
@DELETE
@Path("/{externaltype}/{externalid}")
@@ -266,7 +266,7 @@ public class UserWebService extends BaseWebService {
return performCall(sid, User.Right.ADMIN, sd -> {
User user = userDao.getExternalUser(externalId,
externalType);
- // Setting USER deleted
+ // Setting user deleted
userDao.delete(user, sd.getUserId());
return new ServiceResult("Deleted", Type.SUCCESS);
@@ -275,13 +275,13 @@ public class UserWebService extends BaseWebService {
/**
* Description: sets the SessionObject for a certain SID, after setting
this
- * Session-Object you can use the SID + a RoomId to enter any ROOM. ...
+ * Session-Object you can use the SID + a RoomId to enter any Room. ...
* Session-Hashs are deleted 15 minutes after the creation if not used.
*
* @param sid
* The SID from getSession
- * @param USER
- * USER details to set
+ * @param user
+ * user details to set
* @param options
* room options to set
*
@@ -292,7 +292,7 @@ public class UserWebService extends BaseWebService {
@Path("/hash")
public ServiceResult getRoomHash(
@WebParam(name="sid") @QueryParam("sid") String sid
- , @WebParam(name="USER") @FormParam("USER")
ExternalUserDTO user
+ , @WebParam(name="user") @FormParam("user")
ExternalUserDTO user
, @WebParam(name="options") @FormParam("options")
RoomOptionsDTO options
)
{