diff --git a/pkg/bee/api/act.go b/pkg/bee/api/act.go index eac830b0e..404f8591b 100644 --- a/pkg/bee/api/act.go +++ b/pkg/bee/api/act.go @@ -40,7 +40,7 @@ func (a *ActService) Upload(ctx context.Context, name string, data io.Reader, o return resp, err } -func (a *ActService) AddGrantees(ctx context.Context, name string, data io.Reader, o UploadOptions) (ActGranteesResponse, error) { +func (a *ActService) AddGrantees(ctx context.Context, data io.Reader, o UploadOptions) (ActGranteesResponse, error) { var resp ActGranteesResponse h := http.Header{} h.Add(postageStampBatchHeader, o.BatchID) @@ -53,7 +53,7 @@ func (a *ActService) GetGrantees(ctx context.Context, addr swarm.Address) (resp return a.client.requestData(ctx, http.MethodGet, "/"+apiVersion+"/grantee/"+addr.String(), nil, nil) } -func (a *ActService) PatchGrantees(ctx context.Context, name string, data io.Reader, addr swarm.Address, haddr swarm.Address, batchID string) (ActGranteesResponse, error) { +func (a *ActService) PatchGrantees(ctx context.Context, data io.Reader, addr swarm.Address, haddr swarm.Address, batchID string) (ActGranteesResponse, error) { var resp ActGranteesResponse h := http.Header{} h.Add("swarm-postage-batch-id", batchID) diff --git a/pkg/bee/client.go b/pkg/bee/client.go index a3114aedd..54d938699 100644 --- a/pkg/bee/client.go +++ b/pkg/bee/client.go @@ -229,7 +229,6 @@ func (c *Client) DownloadActFile(ctx context.Context, a swarm.Address, opts *api if err != nil { return 0, nil, fmt.Errorf("download file %s: %w", a, err) } - defer r.Close() h := fileHasher() size, err = io.Copy(h, r) @@ -783,7 +782,7 @@ func (c *Client) UploadActFile(ctx context.Context, f *File, o api.UploadOptions func (c *Client) AddActGrantees(ctx context.Context, f *File, o api.UploadOptions) (err error) { h := fileHasher() - r, err := c.api.Act.AddGrantees(ctx, f.Name(), io.TeeReader(f.DataReader(), h), o) + r, err := c.api.Act.AddGrantees(ctx, io.TeeReader(f.DataReader(), h), o) if err != nil { return fmt.Errorf("add ACT grantees: %w", err) } @@ -806,7 +805,7 @@ func (c *Client) GetActGrantees(ctx context.Context, a swarm.Address) (addresses } func (c *Client) PatchActGrantees(ctx context.Context, pf *File, addr swarm.Address, haddr swarm.Address, batchID string) (err error) { - r, err := c.api.Act.PatchGrantees(ctx, pf.Name(), pf.DataReader(), addr, haddr, batchID) + r, err := c.api.Act.PatchGrantees(ctx, pf.DataReader(), addr, haddr, batchID) if err != nil { return fmt.Errorf("add ACT grantees: %w", err) } diff --git a/pkg/check/act/act.go b/pkg/check/act/act.go index 446803e49..caed26d78 100644 --- a/pkg/check/act/act.go +++ b/pkg/check/act/act.go @@ -55,7 +55,6 @@ func NewCheck(logger logging.Logger) beekeeper.Action { // Run executes act check func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts interface{}) (err error) { - c.logger.Info("ACT test started") o, ok := opts.(Options) if !ok { return fmt.Errorf("invalid options type") @@ -230,7 +229,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int return fmt.Errorf("node %s: PatchActGrantees: %w", upNodeName, pErr) } c.logger.Info("ACT grantees patched") - time.Sleep(5 * time.Second) + time.Sleep(15 * time.Second) // list grantees after patch // ---------------------------------------------- @@ -249,9 +248,21 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int } c.logger.Info("ACT grantees listed after patch") + // download act file with the not enabled grantee after patch + //---------------------------------------------- + // Given the grantee is patched + // When the file is downloaded from the node with the not enabled grantee + // Then the file download is denied + hG := pFile.HistroryAddress() + _, _, notGErr := client2.DownloadActFile(ctx, fileAddress, &api.DownloadOptions{Act: &act, ActPublicKey: &publisher, ActHistoryAddress: &hG}) + if notGErr == nil { + return fmt.Errorf("node %s: File downloaded with wrong public key successfully - this is an error", nodeName2) + } + c.logger.Info("ACT Access denied for not enabled grantee after patch") + // download act file with the new grantee after patch // ---------------------------------------------- - // Given the grantee is patched + // Given that the grantee has been patched // When the file is downloaded from the node with the new grantee // Then the file is downloaded successfully his2 := pFile.HistroryAddress() @@ -264,7 +275,5 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int return errors.New("ACT file retrieval - hash error") } c.logger.Info("ACT file downloaded with the new grantee after patch") - - c.logger.Info("ACT test completed") return }