mengw15 commented on code in PR #7222:
URL: https://github.com/apache/texera/pull/7222#discussion_r3694812619


##########
amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectAccessResourceSpec.scala:
##########
@@ -129,4 +139,101 @@ class ProjectAccessResourceSpec
     assert(privilege == PrivilegeEnum.NONE)
     assert(!ProjectAccessResource.userHasWriteAccess(privateProject.getPid, 
readerUid))
   }
+
+  it should "return WRITE and grant write access for a WRITE grantee" in {
+    val project = projectResource.createProject(new SessionUser(owner), 
"writer-project")
+    projectUserAccessDao.merge(
+      new ProjectUserAccess(writerUid, project.getPid, PrivilegeEnum.WRITE)
+    )
+
+    assert(
+      ProjectAccessResource.getProjectAccessPrivilege(
+        project.getPid,
+        writerUid
+      ) == PrivilegeEnum.WRITE
+    )
+    assert(ProjectAccessResource.userHasWriteAccess(project.getPid, writerUid))
+  }
+
+  "ProjectAccessResource.getOwner" should "return the owning user's email" in {
+    val project = projectResource.createProject(new SessionUser(owner), 
"owned-project")
+    assert(projectAccessResource.getOwner(project.getPid) == owner.getEmail)
+  }
+
+  "ProjectAccessResource.getAccessList" should "be empty when only the owner 
has access" in {
+    val project = projectResource.createProject(new SessionUser(owner), 
"solo-project")
+    // createProject grants the owner WRITE, but getAccessList excludes the 
owner.
+    assert(projectAccessResource.getAccessList(project.getPid).asScala.isEmpty)
+  }
+
+  it should "list every grantee (excluding the owner) with their email, name 
and privilege" in {
+    val project = projectResource.createProject(new SessionUser(owner), 
"shared-list-project")
+    projectUserAccessDao.merge(new ProjectUserAccess(readerUid, 
project.getPid, PrivilegeEnum.READ))
+    projectUserAccessDao.merge(
+      new ProjectUserAccess(writerUid, project.getPid, PrivilegeEnum.WRITE)
+    )
+
+    val entries = 
projectAccessResource.getAccessList(project.getPid).asScala.toList
+    assert(entries.size == 2)
+    assert(!entries.map(_.email).contains(owner.getEmail)) // owner is excluded
+    assert(entries.contains(AccessEntry(reader.getEmail, reader.getName, 
PrivilegeEnum.READ)))
+    assert(entries.contains(AccessEntry(writer.getEmail, writer.getName, 
PrivilegeEnum.WRITE)))
+  }
+
+  "ProjectAccessResource.grantAccess" should "let a writer grant READ access 
to another user" in {

Review Comment:
   Adopted — the seeded `writer` is now granted WRITE and performs the grant, 
so the test name matches and a non-owner WRITE-grantee grant path is exercised.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to