Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
statetest: Config source app-scoped project inheritance.
Browse files Browse the repository at this point in the history
  • Loading branch information
paladin-devops committed Jun 28, 2023
1 parent 076667d commit e1a73ae
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pkg/serverstate/statetest/test_config_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,51 @@ func TestConfigSource(t *testing.T, factory Factory, restartF RestartFactory) {
require.Equal("abc", resp[0].Config["token"])
require.Equal("123", resp[1].Config["token"])
})

t.Run("app scoped config source inheritance from project", func(t *testing.T) {
require := require.New(t)

s := factory(t)
defer s.Close()

require.NoError(s.ProjectPut(ctx, &pb.Project{
Name: "testProject",
}))

_, err := s.AppPut(ctx, &pb.Application{
Project: &pb.Ref_Project{Project: "testProject"},
Name: "testApp",
})
require.NoError(err)

// Create a config source at the project scope
require.NoError(s.ConfigSourceSet(ctx, &pb.ConfigSource{
Scope: &pb.ConfigSource_Project{
Project: &pb.Ref_Project{
Project: "testProject",
},
},

Type: "vault",
Config: map[string]string{
"token": "project",
},
}))

// do a config source get request at the app scope
resp, err := s.ConfigSourceGet(ctx, &pb.GetConfigSourceRequest{
Scope: &pb.GetConfigSourceRequest_Application{
Application: &pb.Ref_Application{
Application: "testApp",
Project: "testProject",
},
},
Type: "vault",
})
require.NoError(err)
require.Equal(1, len(resp))
require.Equal("project", resp[0].Config["token"])
})
}

func TestConfigSourceWatch(t *testing.T, factory Factory, restartF RestartFactory) {
Expand Down

0 comments on commit e1a73ae

Please sign in to comment.