From 04cc57538f572caaddcb08c0eea7496e2c36d3cc Mon Sep 17 00:00:00 2001 From: sfc-gh-ext-simba-lb Date: Mon, 31 Oct 2022 13:58:49 -0700 Subject: [PATCH] ignore405Error --- file_transfer_agent.go | 2 ++ file_transfer_agent_test.go | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 file_transfer_agent_test.go diff --git a/file_transfer_agent.go b/file_transfer_agent.go index fa7d80b5a..3b8cb1a3e 100644 --- a/file_transfer_agent.go +++ b/file_transfer_agent.go @@ -615,6 +615,8 @@ func (sfa *snowflakeFileTransferAgent) transferAccelerateConfig() error { if errors.As(err, &ae) { if ae.ErrorCode() == "AccessDenied" { return nil + } else if ae.ErrorCode() == "MethodNotAllowed" { + return nil } } return err diff --git a/file_transfer_agent_test.go b/file_transfer_agent_test.go new file mode 100644 index 000000000..284eacd7a --- /dev/null +++ b/file_transfer_agent_test.go @@ -0,0 +1,44 @@ +// Copyright (c) 2022 Snowflake Computing Inc. All rights reserved. + +package gosnowflake + +import ( + "context" + "errors" + "testing" + + "github.com/aws/smithy-go" +) + +func TestGetBucketAccelerateConfiguration(t *testing.T) { + if runningOnGithubAction() { + t.Skip("Should be run against an account in AWS EU North1 region.") + } + config, err := ParseDSN(dsn) + if err != nil { + t.Error(err) + } + sc, err := buildSnowflakeConn(context.Background(), *config) + if err != nil { + t.Fatal(err) + } + if err = authenticateWithConfig(sc); err != nil { + t.Fatal(err) + } + sfa := &snowflakeFileTransferAgent{ + sc: sc, + commandType: uploadCommand, + srcFiles: make([]string, 0), + data: &execResponseData{ + SrcLocations: make([]string, 0), + }, + } + if err = sfa.transferAccelerateConfig(); err != nil { + var ae smithy.APIError + if errors.As(err, &ae) { + if ae.ErrorCode() == "MethodNotAllowed" { + t.Fatalf("should have ignored 405 error: %v", err) + } + } + } +}