MCPcopy Create free account
hub / github.com/coder/envbuilder / TestBuildIgnoreVarRunSecrets

Function TestBuildIgnoreVarRunSecrets

integration/integration_test.go:833–878  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

831}
832
833func TestBuildIgnoreVarRunSecrets(t *testing.T) {
834 t.Parallel()
835
836 // Ensures that a Git repository with a Dockerfile is cloned and built.
837 srv := gittest.CreateGitServer(t, gittest.Options{
838 Files: map[string]string{
839 "Dockerfile": "FROM " + testImageAlpine,
840 },
841 })
842 dir := t.TempDir()
843 secretVal := uuid.NewString()
844 err := os.WriteFile(filepath.Join(dir, "secret"), []byte(secretVal), 0o644)
845 require.NoError(t, err)
846
847 t.Run("ReadWrite", func(t *testing.T) {
848 t.Parallel()
849
850 ctr, err := runEnvbuilder(t, runOpts{
851 env: []string{
852 envbuilderEnv("GIT_URL", srv.URL),
853 envbuilderEnv("DOCKERFILE_PATH", "Dockerfile"),
854 },
855 binds: []string{fmt.Sprintf("%s:/var/run/secrets:rw", dir)},
856 })
857 require.NoError(t, err)
858
859 output := execContainer(t, ctr, "cat /var/run/secrets/secret")
860 require.Equal(t, secretVal, strings.TrimSpace(output))
861 })
862
863 t.Run("ReadOnly", func(t *testing.T) {
864 t.Parallel()
865
866 ctr, err := runEnvbuilder(t, runOpts{
867 env: []string{
868 envbuilderEnv("GIT_URL", srv.URL),
869 envbuilderEnv("DOCKERFILE_PATH", "Dockerfile"),
870 },
871 binds: []string{fmt.Sprintf("%s:/var/run/secrets:ro", dir)},
872 })
873 require.NoError(t, err)
874
875 output := execContainer(t, ctr, "cat /var/run/secrets/secret")
876 require.Equal(t, secretVal, strings.TrimSpace(output))
877 })
878}
879
880func TestBuildWithSetupScript(t *testing.T) {
881 t.Parallel()

Callers

nothing calls this directly

Calls 5

CreateGitServerFunction · 0.92
runEnvbuilderFunction · 0.85
envbuilderEnvFunction · 0.85
execContainerFunction · 0.85
JoinMethod · 0.80

Tested by

no test coverage detected