Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ object ResourceAccess {
requesterUid: Integer
): Response = {
requireWriteAccess(ctx, resource, id, requesterUid)
val granteeUid = ctx.select(USER.UID).from(USER).where(USER.EMAIL.eq(email)).fetchOne().value1()
val granteeUid = OwnerAccess
.registeredUid(ctx, email)
.getOrElse(throw new BadRequestException(s"No registered user with email $email"))
OwnerAccess.requireNotOwner(userOwns(ctx, resource, id, granteeUid))

ctx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.texera.service.resource

import jakarta.ws.rs.ForbiddenException
import jakarta.ws.rs.{BadRequestException, ForbiddenException}
import org.apache.texera.dao.MockTexeraDB
import org.apache.texera.dao.jooq.generated.enums.{PrivilegeEnum, UserRoleEnum}
import org.apache.texera.dao.jooq.generated.tables.DatasetUserAccess.DATASET_USER_ACCESS
Expand Down Expand Up @@ -263,4 +263,11 @@ class ResourceAccessSpec
.getStatus shouldBe 200
rowOf(grantee.getUid) shouldBe None
}

it should "reject an unregistered email with 400, not crash with a 500" in {
val ex = intercept[BadRequestException] {
ResourceAccess.revoke(getDSLContext, resource, did, "nobody@test.com", owner.getUid)
}
ex.getResponse.getStatus shouldBe 400
}
}
Loading