Commit 8b35e7ab by zhangying

资料云盘-公共文件-权限管理

parent aee8a44e
...@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
import com.live.enums.ApiModele; import com.live.enums.ApiModele;
import com.live.enums.RequestType; import com.live.enums.RequestType;
import com.live.enums.Terminal; import com.live.enums.Terminal;
import com.live.utils.RandomStringUtil;
import com.live.utils.XMBaseTest; import com.live.utils.XMBaseTest;
import com.live.xmutils.GetFolderData; import com.live.xmutils.GetFolderData;
import org.testng.Assert; import org.testng.Assert;
...@@ -29,34 +28,75 @@ public class TestAddFileUserAuthorityList extends XMBaseTest { ...@@ -29,34 +28,75 @@ public class TestAddFileUserAuthorityList extends XMBaseTest {
} }
/** /**
* 测试资料云盘-公共文件夹添加成员 * 测试资料云盘-公共文件夹添加成员,新文件夹
*/ */
@Test @Test
public void testAddFileUserAuthorityList() { public void testAddFileUserAuthorityList() {
GetFolderData commonFolderList = new GetFolderData(); GetFolderData commonFolderList = new GetFolderData();
JSONObject FolderList = commonFolderList.getCommonFolderList(); JSONObject folderData = commonFolderList.saveFolder();
System.out.println("FolderList= " + FolderList); String folderId = folderData.getJSONObject("result").getString("id");
String userId = "1244920914395918338"; //测试文件夹添加员工,员工固定,名称为"自动化测试员工"
JSONObject rightsListObject = new JSONObject(); JSONObject rightsListObject = new JSONObject();
rightsListObject.put("rights","LOOK_DOWNLOAD"); rightsListObject.put("rights","LOOK_DOWNLOAD");
rightsListObject.put("userId","1244920914395918338"); rightsListObject.put("userId",userId);
List rightsList = new ArrayList(); List rightsList = new ArrayList();
rightsList.add(rightsListObject); rightsList.add(rightsListObject);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("instId", "1235115978015883266"); jsonObject.put("instId", xmAppApi.getLoginInfo().getInstId());
jsonObject.put("id", "1362659086265585665"); jsonObject.put("id", folderId); //公共文件夹的文件夹id
jsonObject.put("createId",xmAppApi.getLoginInfo().getAid()); jsonObject.put("createId",xmAppApi.getLoginInfo().getAid());
jsonObject.put("disk", "COMMON"); jsonObject.put("disk", "COMMON");
jsonObject.put("rightsList", rightsList); jsonObject.put("rightsList", rightsList);
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers); xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
JSONObject jsonBody = xmAppApi.getBodyInJSON(); JSONObject jsonBody = xmAppApi.getBodyInJSON();
System.out.println("jsonBody = "+jsonBody); System.out.println("jsonBody = "+jsonBody);
JSONObject userAuthority = commonFolderList.getFileUserAuthority(folderId);
String userId1 = userAuthority.getJSONArray("result").getJSONObject(1).getString("userId");
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals(userId,userId1);
}
/**
* 测试资料云盘-公共文件夹添加成员,文件夹中二次添加成员
*/
@Test
public void testAddFileUserAuthorityLis1t() throws InterruptedException {
GetFolderData commonFolderList = new GetFolderData();
JSONObject folderList = commonFolderList.getCommonFolderList();
String folderId = folderList.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
String userId = "1235119462038163457"; //测试文件夹添加员工,员工固定,名称为"自动化测试员工"
JSONObject rightsListObject = new JSONObject();
rightsListObject.put("rights","LOOK_DOWNLOAD");
rightsListObject.put("userId",userId);
List rightsList = new ArrayList();
rightsList.add(rightsListObject);
JSONObject jsonObject = new JSONObject();
jsonObject.put("instId", xmAppApi.getLoginInfo().getInstId());
jsonObject.put("id", folderId); //公共文件夹的文件夹id
jsonObject.put("createId",xmAppApi.getLoginInfo().getAid());
jsonObject.put("disk", "COMMON");
jsonObject.put("rightsList", rightsList);
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
JSONObject userAuthority = commonFolderList.getFileUserAuthority(folderId);
String userId1 = userAuthority.getJSONArray("result").getJSONObject(1).getString("userId");
System.out.println("userAuthority =="+userAuthority);
Assert.assertEquals("true", jsonBody.getString("success")); Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals(userId,userId1);
} }
} }
package com.live.cases.fileManage.commonFolder;
import com.alibaba.fastjson.JSONObject;
import com.live.enums.ApiModele;
import com.live.enums.RequestType;
import com.live.enums.Terminal;
import com.live.utils.XMBaseTest;
import com.live.xmutils.GetFolderData;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* @author zhangying
* @date 2021/2/23 7:26 下午
*/
public class TestUpdateFileUserAuthority extends XMBaseTest {
@BeforeMethod
public void beforeTest() {
xmAppApi.setApiModule(ApiModele.CloudClass_File) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_updateFileUserAuthority") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
super.beforeTest();
}
/**
* 测试资料云盘-公共文件夹成员管理,修改权限,可查看/下载——>可编辑
*/
@Test
public void testUpdateFileUserAuthority() throws InterruptedException {
GetFolderData commonFolderList = new GetFolderData();
JSONObject folderList = commonFolderList.getCommonFolderList();
String folderId = folderList.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
JSONObject userAuthority = commonFolderList.getFileUserAuthority(folderId);
String updateId = userAuthority.getJSONArray("result").getJSONObject(0).getString("userId");//操作账户的userId
String userId = userAuthority.getJSONArray("result").getJSONObject(1).getString("userId");
JSONObject jsonObject = new JSONObject();
jsonObject.put("instId", xmAppApi.getLoginInfo().getInstId());
jsonObject.put("id", folderId);
jsonObject.put("userId", userId);
jsonObject.put("updateId", updateId);
jsonObject.put("rights", "EDIT");
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
JSONObject userAuthority1 = commonFolderList.getFileUserAuthority(folderId);
String userRights = userAuthority1.getJSONArray("result").getJSONObject(1).getString("rights");
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("EDIT", userRights);
}
/**
* 测试资料云盘-公共文件夹添加员工,可编辑——>可查看/下载
*/
@Test
public void testUpdateFileUserAuthority1() throws InterruptedException {
GetFolderData commonFolderList = new GetFolderData();
JSONObject folderList = commonFolderList.getCommonFolderList();
String folderId = folderList.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
JSONObject userAuthority = commonFolderList.getFileUserAuthority(folderId);
String updateId = userAuthority.getJSONArray("result").getJSONObject(0).getString("userId");//操作账户的userId
String userId = userAuthority.getJSONArray("result").getJSONObject(1).getString("userId");
JSONObject jsonObject = new JSONObject();
jsonObject.put("instId", xmAppApi.getLoginInfo().getInstId());
jsonObject.put("id", folderId);
jsonObject.put("userId", userId);
jsonObject.put("updateId", updateId);
jsonObject.put("rights", "LOOK_DOWNLOAD");
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
System.out.println("jsonBody = "+jsonBody);
JSONObject userAuthority1 = commonFolderList.getFileUserAuthority(folderId);
String userRights = userAuthority1.getJSONArray("result").getJSONObject(1).getString("rights");
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("LOOK_DOWNLOAD", userRights);
}
/**
* 测试资料云盘-公共文件夹添加员工,操作账户无操作权限
*/
@Test
public void testUpdateFileUserAuthority2() throws InterruptedException {
GetFolderData commonFolderList = new GetFolderData();
JSONObject folderList = commonFolderList.getCommonFolderList();
String folderId = folderList.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
JSONObject userAuthority = commonFolderList.getFileUserAuthority(folderId);
String userId = userAuthority.getJSONArray("result").getJSONObject(1).getString("userId");
JSONObject jsonObject = new JSONObject();
jsonObject.put("instId", xmAppApi.getLoginInfo().getInstId());
jsonObject.put("id", folderId);
jsonObject.put("userId", userId);
jsonObject.put("updateId", System.currentTimeMillis());
jsonObject.put("rights", "EDIT");
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
System.out.println("jsonBody = "+jsonBody);
Assert.assertEquals("false", jsonBody.getString("success"));
Assert.assertEquals("当前没有操作权限", jsonBody.getString("message"));
}
/**
* 测试资料云盘-公共文件夹添加员工,从列表中移除员工
*/
@Test
public void testUpdateFileUserAuthority3() throws InterruptedException {
GetFolderData commonFolderList = new GetFolderData();
JSONObject folderList = commonFolderList.getCommonFolderList();
String folderId = folderList.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
System.out.println("folderId = " + folderId);
JSONObject userAuthority = commonFolderList.getFileUserAuthority(folderId);
String updateId = userAuthority.getJSONArray("result").getJSONObject(0).getString("userId");//操作账户的userId
String userId = userAuthority.getJSONArray("result").getJSONObject(1).getString("userId");
System.out.println("userAuthority =="+userAuthority);
JSONObject jsonObject = new JSONObject();
jsonObject.put("currentRight", "LOOK_DOWNLOAD");
jsonObject.put("instId", xmAppApi.getLoginInfo().getInstId());
jsonObject.put("id", folderId);
jsonObject.put("userId", userId);
jsonObject.put("updateId", updateId);
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
JSONObject jsonBody = xmAppApi.getBodyInJSON();
System.out.println("jsonBody = "+jsonBody);
JSONObject userAuthority1 = commonFolderList.getFileUserAuthority(folderId);
Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertNotEquals(userAuthority1.getJSONArray("result").size(),userAuthority.getJSONArray("result").size());
}
}
...@@ -98,7 +98,6 @@ public class TestAddCourseStu extends XMBaseTest { ...@@ -98,7 +98,6 @@ public class TestAddCourseStu extends XMBaseTest {
JSONObject onlyOneCourseList = onlyOneCourseData.getOnlyOneCourseList(); JSONObject onlyOneCourseList = onlyOneCourseData.getOnlyOneCourseList();
String studentId1 = onlyOneCourseList.getJSONObject("result").getJSONArray("records").getJSONObject(0).getJSONArray("liveStudentBaseVO").getJSONObject(0).getString("studentId"); String studentId1 = onlyOneCourseList.getJSONObject("result").getJSONArray("records").getJSONObject(0).getJSONArray("liveStudentBaseVO").getJSONObject(0).getString("studentId");
// System.out.println("onlyOneCourseList = "+onlyOneCourseList);
Assert.assertEquals("true", jsonBody.getString("success")); Assert.assertEquals("true", jsonBody.getString("success"));
Assert.assertEquals("操作成功!", jsonBody.getString("message")); Assert.assertEquals("操作成功!", jsonBody.getString("message"));
......
...@@ -17,13 +17,13 @@ import static io.restassured.RestAssured.given; ...@@ -17,13 +17,13 @@ import static io.restassured.RestAssured.given;
public class GetFolderData extends XMBaseTest { public class GetFolderData extends XMBaseTest {
public String saveFolder() { public JSONObject saveFolder() {
dataApi.setApiModule(ApiModele.CloudClass_File) // API 所属模块 必传 读取配置文件config.properties配置的api地址 dataApi.setApiModule(ApiModele.CloudClass_File) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_saveFolder") // API 名称 必传 .setApiName("API_saveFolder") // API 名称 必传
.setLoginUser("zhangy-b") // http 接口,测试账号 必传 .setLoginUser("zhangy-b") // http 接口,测试账号 必传
.setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传) .setTerminal(Terminal.B); // 所属端位(B端,C端,M端等, 必传)
super.beforeTest(); super.beforeDataRequest();
String name = "测试文件夹新增"+ RandomStringUtil.randomString(6); //新增文件夹名称 String name = "测试文件夹新增"+ RandomStringUtil.randomString(6); //新增文件夹名称
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -37,11 +37,8 @@ public class GetFolderData extends XMBaseTest { ...@@ -37,11 +37,8 @@ public class GetFolderData extends XMBaseTest {
dataApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers); dataApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
System.out.println(dataApi); System.out.println(dataApi);
JSONObject jsonBody = dataApi.getBodyInJSON(); JSONObject jsonBody = dataApi.getBodyInJSON();
System.out.println("新增文件夹返回值 jsonBody =="+jsonBody);
String folderId = jsonBody.getString("result");
System.out.println("folder =="+folderId);
return folderId; return jsonBody;
} }
/** /**
...@@ -104,7 +101,7 @@ public class GetFolderData extends XMBaseTest { ...@@ -104,7 +101,7 @@ public class GetFolderData extends XMBaseTest {
/** /**
* 资料云盘-公共文件-权限管理-员工列表 * 资料云盘-公共文件-权限管理-员工列表
*/ */
public JSONObject getFileUserAuthority() throws InterruptedException { public JSONObject getFileUserAuthority(String folderId) {
dataApi.setApiModule(ApiModele.CloudClass_File) // API 所属模块 必传 读取配置文件config.properties配置的api地址 dataApi.setApiModule(ApiModele.CloudClass_File) // API 所属模块 必传 读取配置文件config.properties配置的api地址
.setApiName("API_getFileUserAuthority") // API 名称 必传 .setApiName("API_getFileUserAuthority") // API 名称 必传
...@@ -113,10 +110,6 @@ public class GetFolderData extends XMBaseTest { ...@@ -113,10 +110,6 @@ public class GetFolderData extends XMBaseTest {
super.beforeDataRequest(); super.beforeDataRequest();
GetFolderData testSaveFolder = new GetFolderData();
String folderId = testSaveFolder.saveFolder();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("id",folderId); jsonObject.put("id",folderId);
jsonObject.put("instId", xmAppApi.getLoginInfo().getInstId()); jsonObject.put("instId", xmAppApi.getLoginInfo().getInstId());
...@@ -125,7 +118,6 @@ public class GetFolderData extends XMBaseTest { ...@@ -125,7 +118,6 @@ public class GetFolderData extends XMBaseTest {
dataApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers); dataApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers);
System.out.println(dataApi); System.out.println(dataApi);
JSONObject jsonBody = dataApi.getBodyInJSON(); JSONObject jsonBody = dataApi.getBodyInJSON();
TimeUnit.SECONDS.sleep(3);
return jsonBody; return jsonBody;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment