Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(agent): SHA256SUMS being looked up in the parent directory #842

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion windows-agent/internal/proservices/landscape/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func download(ctx context.Context, f io.Writer, u *url.URL) (err error) {
// ...
func wantRootfsChecksum(ctx context.Context, u *url.URL) (string, error) {
imageName := filepath.Base(u.Path)
shasRelativeURL, err := url.Parse("../SHA256SUMS")
shasRelativeURL, err := url.Parse("SHA256SUMS")
if err != nil {
return "", fmt.Errorf("could not assemble SHA256SUMS location: %v", err)
}
Expand Down
16 changes: 9 additions & 7 deletions windows-agent/internal/proservices/landscape/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func TestInstall(t *testing.T) {
u := tc.sendRootfsURL
var err error
if tc.sendRootfsURL != brokenURL {
u, err = url.JoinPath(fileServerAddr, tc.sendRootfsURL)
u, err = url.JoinPath(fileServerAddr, "/releases/theone", tc.sendRootfsURL)
require.NoError(t, err, "Setup: could not assemble URL: %s + %s", fileServerAddr, tc.sendRootfsURL)
}

Expand Down Expand Up @@ -329,20 +329,22 @@ func mockRootfsFileServer(t *testing.T, ctx context.Context, enableChecksumsFile

mux := http.NewServeMux()

mux.HandleFunc("GET /goodfile", func(w http.ResponseWriter, r *http.Request) {}) // Return empty file
mux.HandleFunc("GET /badchecksum", func(w http.ResponseWriter, r *http.Request) {}) // Return empty file
mux.HandleFunc("GET /rootfswithnochecksum", func(w http.ResponseWriter, r *http.Request) {}) // intentionally not in the checksums file
mux.HandleFunc("GET /badfile", func(w http.ResponseWriter, r *http.Request) {
const getFile = "GET /releases/theone/%s"

mux.HandleFunc(fmt.Sprintf(getFile, "goodfile"), func(w http.ResponseWriter, r *http.Request) {}) // Return empty file
mux.HandleFunc(fmt.Sprintf(getFile, "badchecksum"), func(w http.ResponseWriter, r *http.Request) {}) // Return empty file
mux.HandleFunc(fmt.Sprintf(getFile, "rootfswithnochecksum"), func(w http.ResponseWriter, r *http.Request) {}) // intentionally not in the checksums file
mux.HandleFunc(fmt.Sprintf(getFile, "badfile"), func(w http.ResponseWriter, r *http.Request) {
_, err := fmt.Fprintf(w, "MOCK_ERROR")
if err != nil {
t.Logf("mockRootfsFileServer: could not write response: %v", err)
}
})
mux.HandleFunc("GET /badresponse", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc(fmt.Sprintf(getFile, "badresponse"), func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
})
if enableChecksumsFile {
mux.HandleFunc("GET /SHA256SUMS", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc(fmt.Sprintf(getFile, "SHA256SUMS"), func(w http.ResponseWriter, r *http.Request) {
_, err := fmt.Fprintf(w, `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 *goodfile
afe55cda4210c2439b47c62c01039027522f7ed4abdb113972b3030b3359532a *badfile
1234 *badchecksum
Expand Down
Loading