Copilot commented on code in PR #7222:
URL: https://github.com/apache/texera/pull/7222#discussion_r3694805921
##########
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:
The test description says "let a writer grant READ access", but the actor
passed to `grantAccess` is `new SessionUser(owner)`, not the seeded `writer`.
This is misleading when reading test failures and coverage intent; either grant
WRITE to `writer` and call as that user, or rename the test to reflect that
it's any user with WRITE access (e.g., the owner).
--
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]