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

Remove use of invalid AWS cred defaults #76

Merged
merged 1 commit into from
Oct 10, 2022
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ becomes `ARCHIVER_LOG_LEVEL`.
-archive-runs
whether we should archive runs (default true)
-aws-access-key-id string
the access key id to use when authenticating S3 (default "missing_aws_access_key_id")
the access key id to use when authenticating S3 (default none)
-aws-secret-access-key string
the secret access key id to use when authenticating S3 (default "missing_aws_secret_access_key")
the secret access key id to use when authenticating S3 (default none)
-db string
the connection string for our database (default "postgres://localhost/archiver_test?sslmode=disable")
-debug-conf
Expand Down
23 changes: 4 additions & 19 deletions archives/archives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ func TestGetMissingDayArchives(t *testing.T) {
// get the tasks for our org
ctx := context.Background()
config := NewDefaultConfig()
config.AWSAccessKeyID = "missing_aws_access_key_id"
config.AWSSecretAccessKey = "missing_aws_secret_access_key"

orgs, err := GetActiveOrgs(ctx, db, config)
assert.NoError(t, err)
Expand Down Expand Up @@ -88,8 +86,7 @@ func TestGetMissingMonthArchives(t *testing.T) {
// get the tasks for our org
ctx := context.Background()
config := NewDefaultConfig()
config.AWSAccessKeyID = "missing_aws_access_key_id"
config.AWSSecretAccessKey = "missing_aws_secret_access_key"

orgs, err := GetActiveOrgs(ctx, db, config)
assert.NoError(t, err)

Expand Down Expand Up @@ -123,8 +120,6 @@ func TestCreateMsgArchive(t *testing.T) {
assert.NoError(t, err)

config := NewDefaultConfig()
config.AWSAccessKeyID = "missing_aws_access_key_id"
config.AWSSecretAccessKey = "missing_aws_secret_access_key"
orgs, err := GetActiveOrgs(ctx, db, config)
assert.NoError(t, err)
now := time.Date(2018, 1, 8, 12, 30, 0, 0, time.UTC)
Expand Down Expand Up @@ -202,8 +197,6 @@ func TestCreateRunArchive(t *testing.T) {
assert.NoError(t, err)

config := NewDefaultConfig()
config.AWSAccessKeyID = "missing_aws_access_key_id"
config.AWSSecretAccessKey = "missing_aws_secret_access_key"
orgs, err := GetActiveOrgs(ctx, db, config)
assert.NoError(t, err)
now := time.Date(2018, 1, 8, 12, 30, 0, 0, time.UTC)
Expand Down Expand Up @@ -261,8 +254,6 @@ func TestWriteArchiveToDB(t *testing.T) {
ctx := context.Background()

config := NewDefaultConfig()
config.AWSAccessKeyID = "missing_aws_access_key_id"
config.AWSSecretAccessKey = "missing_aws_secret_access_key"
orgs, err := GetActiveOrgs(ctx, db, config)
assert.NoError(t, err)
now := time.Date(2018, 1, 8, 12, 30, 0, 0, time.UTC)
Expand Down Expand Up @@ -317,8 +308,6 @@ func TestArchiveOrgMessages(t *testing.T) {
deleteTransactionSize = 1

config := NewDefaultConfig()
config.AWSAccessKeyID = "missing_aws_access_key_id"
config.AWSSecretAccessKey = "missing_aws_secret_access_key"
orgs, err := GetActiveOrgs(ctx, db, config)
assert.NoError(t, err)
now := time.Date(2018, 1, 8, 12, 30, 0, 0, time.UTC)
Expand All @@ -331,7 +320,7 @@ func TestArchiveOrgMessages(t *testing.T) {
config.Delete = true

// AWS S3 config in the environment needed to download from S3
if config.AWSAccessKeyID != "missing_aws_access_key_id" && config.AWSSecretAccessKey != "missing_aws_secret_access_key" {
if config.AWSAccessKeyID != "" && config.AWSSecretAccessKey != "" {
s3Client, err := NewS3Client(config)
assert.NoError(t, err)

Expand Down Expand Up @@ -438,8 +427,6 @@ func TestArchiveOrgRuns(t *testing.T) {
ctx := context.Background()

config := NewDefaultConfig()
config.AWSAccessKeyID = "missing_aws_access_key_id"
config.AWSSecretAccessKey = "missing_aws_secret_access_key"
orgs, err := GetActiveOrgs(ctx, db, config)
assert.NoError(t, err)
now := time.Date(2018, 1, 8, 12, 30, 0, 0, time.UTC)
Expand All @@ -452,7 +439,7 @@ func TestArchiveOrgRuns(t *testing.T) {
config.Delete = true

// AWS S3 config in the environment needed to download from S3
if config.AWSAccessKeyID != "missing_aws_access_key_id" && config.AWSSecretAccessKey != "missing_aws_secret_access_key" {
if config.AWSAccessKeyID != "" && config.AWSSecretAccessKey != "" {
s3Client, err := NewS3Client(config)
assert.NoError(t, err)

Expand Down Expand Up @@ -529,8 +516,6 @@ func TestArchiveOrgRuns(t *testing.T) {
func TestArchiveActiveOrgs(t *testing.T) {
db := setup(t)
config := NewDefaultConfig()
config.AWSAccessKeyID = "missing_aws_access_key_id"
config.AWSSecretAccessKey = "missing_aws_secret_access_key"

os.Args = []string{"rp-archiver"}
loader := ezconf.NewLoader(&config, "archiver", "Archives RapidPro runs and msgs to S3", nil)
Expand All @@ -543,7 +528,7 @@ func TestArchiveActiveOrgs(t *testing.T) {
dates.SetNowSource(dates.NewSequentialNowSource(time.Date(2018, 1, 8, 12, 30, 0, 0, time.UTC)))
defer dates.SetNowSource(dates.DefaultNowSource)

if config.AWSAccessKeyID != "missing_aws_access_key_id" && config.AWSSecretAccessKey != "missing_aws_secret_access_key" {
if config.AWSAccessKeyID != "" && config.AWSSecretAccessKey != "" {
s3Client, err := NewS3Client(config)
assert.NoError(t, err)

Expand Down