Skip to content

Commit

Permalink
revert test changes
Browse files Browse the repository at this point in the history
we don't need default action "viewRow"
and "viewAuthorization"
  • Loading branch information
zingmane committed Oct 10, 2023
1 parent 724a0be commit 985e578
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1136,13 +1136,15 @@ class RetrieveRowModel(val connection: DatabaseConnection)(
assert(row.size >= 3)
val liftedRow = row.lift

(row.headOption, liftedRow(1), liftedRow(2), liftedRow(3)) match {
// Row should have at least = row_id, final_flag, cell_annotations, row_permissions
(liftedRow(0), liftedRow(1), liftedRow(2), liftedRow(3)) match {
// values in case statement are nullable even if they are wrapped in Some, see lift function of Seq
case (Some(rowId: RowId), Some(finalFlag: Boolean), Some(cellAnnotationsStr), Some(permissionsStr)) =>
val cellAnnotations = Option(cellAnnotationsStr)
.map(_.asInstanceOf[String])
.map(Json.fromArrayString)
.getOrElse(Json.emptyArr())
val rawValues = row.drop(3)
val rawValues = row.drop(4)

val rowPermissions = Option(permissionsStr) match {
case Some(permissionsArrayString: String) => new JsonArray(permissionsArrayString)
Expand All @@ -1161,37 +1163,6 @@ class RetrieveRowModel(val connection: DatabaseConnection)(
}
}

// private def mapRowToRawRow2(columns: Seq[ColumnType[_]])(row: Seq[Any]): RawRow = {

// val liftedRow = row.lift

// // Row should have at least = row_id, final_flag, cell_annotations, row_permissions
// (liftedRow(0), liftedRow(1), liftedRow(2), liftedRow(3)) match {
// // values in case statement are nullable even if they are wrapped in Some, see lift function of Seq
// case (Some(rowId: RowId), Some(finalFlag: Boolean), Some(cellAnnotationsStr), Some(permissions)) =>
// val cellAnnotations = Option(cellAnnotationsStr)
// .map(_.asInstanceOf[String])
// .map(Json.fromArrayString)
// .getOrElse(Json.emptyArr())
// val rowPermissions = Option(permissions) match {
// case Some(permissionsArrayString: String) => new JsonArray(permissionsArrayString)
// case _ => Json.arr()
// }
// // All row annotations, currently final and permissions
// val rowAnnotations = Seq(FinalFlag(finalFlag), RowPermissions(rowPermissions))
// val rawValues = row.drop(4)

// RawRow(
// rowId,
// rowAnnotations,
// CellLevelAnnotations(columns, cellAnnotations),
// (columns, rawValues).zipped.map(mapValueByColumnType)
// )
// case _ =>
// throw UnknownServerException(s"Please check generateProjection!")
// }
// }

def size(tableId: TableId): Future[Long] = {
val select = s"SELECT COUNT(*) FROM user_table_$tableId"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,7 @@ class SystemControllerAuthTest_checkAuthorization extends SystemControllerAuthTe
| "viewColumn",
| "viewCellValue",
| "editCellValue",
| "viewTable",
| "viewRow"
| "viewTable"
| ]
| }
| ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.campudus.tableaux.api.media.MediaTestBase
import com.campudus.tableaux.controller.{StructureController, TableauxController}
import com.campudus.tableaux.database._
import com.campudus.tableaux.database.domain.{InfoAnnotationType, Pagination}
import com.campudus.tableaux.database.domain.FinalFlag
import com.campudus.tableaux.database.model.{StructureModel, TableauxModel}
import com.campudus.tableaux.database.model.TableauxModel.TableId
import com.campudus.tableaux.helper.JsonUtils.{toCreateColumnSeq, toRowValueSeq}
Expand Down Expand Up @@ -209,7 +208,7 @@ class TableauxControllerAuthTest_cell extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -245,7 +244,7 @@ class TableauxControllerAuthTest_cell extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -289,7 +288,7 @@ class TableauxControllerAuthTest_cell extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -322,7 +321,7 @@ class TableauxControllerAuthTest_cell extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -355,7 +354,7 @@ class TableauxControllerAuthTest_cell extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -501,7 +500,7 @@ class TableauxControllerAuthTest_row extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -541,7 +540,7 @@ class TableauxControllerAuthTest_row extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -862,7 +861,7 @@ class TableauxControllerAuthTest_row extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -923,7 +922,7 @@ class TableauxControllerAuthTest_row extends TableauxControllerAuthTest {
| "view-rows": [
| {
| "type": "grant",
| "action": ["viewTable", "viewColumn", "viewCellValue", "viewRow"]
| "action": ["viewTable", "viewColumn", "viewCellValue"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1079,7 +1078,7 @@ class TableauxControllerAuthTest_history extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1115,7 +1114,7 @@ class TableauxControllerAuthTest_history extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1146,7 +1145,7 @@ class TableauxControllerAuthTest_history extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1194,7 +1193,7 @@ class TableauxControllerAuthTest_history extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1225,7 +1224,7 @@ class TableauxControllerAuthTest_history extends TableauxControllerAuthTest {
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1447,7 +1446,7 @@ class TableauxControllerAuthTest_annotation extends TableauxControllerAuthTest {

for {
_ <- createTestTable()
_ <- controller.updateRowAnnotations(1, 1, Seq(FinalFlag(true)))
_ <- controller.updateRowAnnotations(1, 1, Some(true))
} yield ()
}

Expand All @@ -1467,7 +1466,7 @@ class TableauxControllerAuthTest_annotation extends TableauxControllerAuthTest {

for {
_ <- createTestTable()
ex <- controller.updateRowAnnotations(1, 1, Seq(FinalFlag(true))).recover({ case ex => ex })
ex <- controller.updateRowAnnotations(1, 1, Some(true)).recover({ case ex => ex })
} yield {
assertEquals(UnauthorizedException(EditRowAnnotation, Seq("view-cells")), ex)
}
Expand All @@ -1489,7 +1488,7 @@ class TableauxControllerAuthTest_annotation extends TableauxControllerAuthTest {

for {
_ <- createTestTable()
_ <- controller.updateRowsAnnotations(1, Seq(FinalFlag(true)))
_ <- controller.updateRowsAnnotations(1, Some(true))
} yield ()
}

Expand All @@ -1513,7 +1512,7 @@ class TableauxControllerAuthTest_annotation extends TableauxControllerAuthTest {

for {
_ <- createTestTable()
ex <- controller.updateRowsAnnotations(1, Seq(FinalFlag(true))).recover({ case ex => ex })
ex <- controller.updateRowsAnnotations(1, Some(true)).recover({ case ex => ex })
} yield {
assertEquals(UnauthorizedException(EditRowAnnotation, Seq("view-cells")), ex)
}
Expand Down Expand Up @@ -1738,7 +1737,7 @@ class TableauxControllerAuthTest_linkCell extends LinkTestBase with TableauxCont
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1778,7 +1777,7 @@ class TableauxControllerAuthTest_linkCell extends LinkTestBase with TableauxCont
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1816,7 +1815,7 @@ class TableauxControllerAuthTest_linkCell extends LinkTestBase with TableauxCont
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down Expand Up @@ -1856,7 +1855,7 @@ class TableauxControllerAuthTest_linkCell extends LinkTestBase with TableauxCont
| "view-all-cells": [
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"],
| "action": ["viewTable"],
| "condition": {
| "table": {
| "id": "2"
Expand Down Expand Up @@ -2148,7 +2147,7 @@ class TableauxControllerAuthTest_completeTable extends TableauxControllerAuthTes
| },
| {
| "type": "grant",
| "action": ["viewTable", "viewRow"]
| "action": ["viewTable"]
| }
| ]
|}""".stripMargin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ class IdentifierTest extends TableauxTestBase {
// single link into table 3 row 1
Json.obj(
"id" -> rowIds3.head,
"viewAuthorization" -> true,
"value" -> Json.arr(
321,
Json.obj("de-DE" -> "table3col3row1-de", "en_GB" -> "table3col3row1-gb"),
Expand Down
Loading

0 comments on commit 985e578

Please sign in to comment.