Skip to content

Commit

Permalink
fix(permissions): ensure lower case for resource name in fiat_permiss…
Browse files Browse the repository at this point in the history
…ion and fiat_resource tables (backport #963) (#979)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: armory-abedonik <106548537+armory-abedonik@users.noreply.github.com>
  • Loading branch information
mergify[bot] and armory-abedonik authored Sep 29, 2022
1 parent d27a99e commit 523c5fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class SqlPermissionsRepository(

insert.apply {
chunk.forEach { resource ->
values(id, resource.type, resource.name)
values(id, resource.type, resource.name.toLowerCase())
when (jooq.dialect()) {
SQLDialect.POSTGRES ->
onConflictDoNothing()
Expand Down Expand Up @@ -528,7 +528,7 @@ class SqlPermissionsRepository(

insert.apply {
chunk.forEach {
values(it.type, it.name, bodies[it], hashes[it], now)
values(it.type, it.name.toLowerCase(), bodies[it], hashes[it], now)
when (jooq.dialect()) {
// https://github.com/jOOQ/jOOQ/issues/5975 means we have to duplicate field names here
SQLDialect.POSTGRES ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ internal object SqlPermissionsRepositoryTests : JUnit5Minutests {
.isEqualTo("""{"name":"account","permissions":{}}""")
expectThat(resourceBody(jooq, "testuser", app1.resourceType, app1.name).get())
.isEqualTo("""{"name":"app","permissions":{},"details":{}}""")
expectThat(resourceBody(jooq, "testuser", serviceAccount1.resourceType, serviceAccount1.name).get())
expectThat(resourceBody(jooq, "testuser", serviceAccount1.resourceType, serviceAccount1.name.toLowerCase()).get())
.isEqualTo("""{"name":"serviceAccount","memberOf":["role1"]}""")
expectThat(resourceBody(jooq, "testuser", role1.resourceType, role1.name).get())
.isEqualTo("""{"name":"role1"}""")
Expand Down

0 comments on commit 523c5fc

Please sign in to comment.