@@ -294,6 +294,74 @@ defmodule Console.GraphQl.PluralQueriesTest do
294294 assert app [ "name" ] == "app"
295295 assert app [ "spec" ] [ "descriptor" ] [ "type" ] == "app"
296296 end
297+
298+ test "admins can sideload configuration by name" do
299+ user = insert ( :user , roles: % { admin: true } )
300+ expect ( Kazan , :run , fn _ -> { :ok , application ( "app" ) } end )
301+ expect ( Console.Deployer , :file , 2 , fn _ -> { :ok , "found" } end )
302+
303+ { :ok , % { data: % { "application" => app } } } = run_query ( """
304+ query App($name: String!) {
305+ application(name: $name) {
306+ name
307+ spec { descriptor { type } }
308+ configuration {
309+ terraform
310+ helm
311+ }
312+ }
313+ }
314+ """ , % { "name" => "app" } , % { current_user: user } )
315+
316+ assert app [ "name" ] == "app"
317+ assert app [ "spec" ] [ "descriptor" ] [ "type" ] == "app"
318+ assert app [ "configuration" ] [ "helm" ] == "found"
319+ assert app [ "configuration" ] [ "terraform" ] == "found"
320+ end
321+
322+ test "users w/ rbac can sideload configuration by name" do
323+ user = insert ( :user )
324+ setup_rbac ( user , [ "app" ] , configure: true )
325+ expect ( Kazan , :run , fn _ -> { :ok , application ( "app" ) } end )
326+ expect ( Console.Deployer , :file , 2 , fn _ -> { :ok , "found" } end )
327+
328+ { :ok , % { data: % { "application" => app } } } = run_query ( """
329+ query App($name: String!) {
330+ application(name: $name) {
331+ name
332+ spec { descriptor { type } }
333+ configuration {
334+ terraform
335+ helm
336+ }
337+ }
338+ }
339+ """ , % { "name" => "app" } , % { current_user: user } )
340+
341+ assert app [ "name" ] == "app"
342+ assert app [ "spec" ] [ "descriptor" ] [ "type" ] == "app"
343+ assert app [ "configuration" ] [ "helm" ] == "found"
344+ assert app [ "configuration" ] [ "terraform" ] == "found"
345+ end
346+
347+ test "users w/o rbac cannot sideload configuration by name" do
348+ user = insert ( :user )
349+ setup_rbac ( user , [ "other-app" ] , configure: true )
350+ expect ( Kazan , :run , fn _ -> { :ok , application ( "app" ) } end )
351+
352+ { :ok , % { errors: [ _ | _ ] } } = run_query ( """
353+ query App($name: String!) {
354+ application(name: $name) {
355+ name
356+ spec { descriptor { type } }
357+ configuration {
358+ terraform
359+ helm
360+ }
361+ }
362+ }
363+ """ , % { "name" => "app" } , % { current_user: user } )
364+ end
297365 end
298366
299367 defp as_connection ( nodes ) do
0 commit comments