Skip to content

Commit

Permalink
Merge pull request nyaruka#76 from nyaruka/cleanup
Browse files Browse the repository at this point in the history
Remove use of invalid AWS cred defaults
  • Loading branch information
rowanseymour authored Oct 10, 2022
2 parents f4b51fc + 6d9776e commit 2f347a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
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

0 comments on commit 2f347a3

Please sign in to comment.