Skip to content

Commit

Permalink
fix: service endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
maxneuvians authored Jan 20, 2024
1 parent 93f4c55 commit a86d79b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pull_requests_lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
go-tests:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
container: ubuntu

services:
dynamodb-local:
Expand Down Expand Up @@ -43,3 +42,6 @@ jobs:

- name: Test
run: make test
env:
DYNAMODB_ENDPOINT: http://localhost:9000
KMS_ENDPOINT: http://localhost:8080
17 changes: 14 additions & 3 deletions encryption/aws_kms_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
package encryption

import (
"os"
"testing"
)

func getKmsHost() string {
host := "http://kms-local:8080"

if h := os.Getenv("KMS_HOST"); h != "" {
host = h
}

return host
}

func TestAwsKmsEncryptionInitMissingKeyId(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -38,7 +49,7 @@ func TestAwsKmsEncryptionInitValid(t *testing.T) {
e := AwsKmsEncryption{}

err := e.Init(map[string]string{
"endpoint": "http://localhost:4566",
"endpoint": getKmsHost(),
"kms_key_id": "test",
"region": "ca-central-1",
})
Expand All @@ -54,7 +65,7 @@ func TestAwsKmsEncryptionEncrypt(t *testing.T) {
e := AwsKmsEncryption{}

_ = e.Init(map[string]string{
"endpoint": "http://kms-local:8080",
"endpoint": getKmsHost(),
"kms_key_id": "bc436485-5092-42b8-92a3-0aa8b93536dc", // Set in .devcontainer/docker/kms/init.yml
"region": "ca-central-1",
})
Expand Down Expand Up @@ -82,7 +93,7 @@ func TestAwsKmsEncryptionDecrypt(t *testing.T) {
e := AwsKmsEncryption{}

_ = e.Init(map[string]string{
"endpoint": "http://kms-local:8080",
"endpoint": getKmsHost(),
"kms_key_id": "bc436485-5092-42b8-92a3-0aa8b93536dc", // Set in .devcontainer/docker/kms/init.yml
"region": "ca-central-1",
})
Expand Down
21 changes: 16 additions & 5 deletions storage/dynamodb_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package storage

import (
"os"
"testing"
"time"

"github.com/google/uuid"
)

func getDynamoDBHost() string {
host := "http://dynamodb-local:8000"

if h := os.Getenv("DYNAMODB_HOST"); h != "" {
host = h
}

return host
}

func TestDynamoDBBackendDelete(t *testing.T) {
t.Parallel()

backend := DynamoDBBackend{}

_ = backend.Init(map[string]string{
"endpoint": "http://dynamodb-local:8000",
"endpoint": getDynamoDBHost(),
"region": "ca-central-1",
"table_name": "test",
})
Expand Down Expand Up @@ -76,7 +87,7 @@ func TestDynamoDBBackendInitWithEndpoint(t *testing.T) {
err := backend.Init(map[string]string{
"region": "ca-central-1",
"table_name": "test",
"endpoint": "http://localhost:8000",
"endpoint": getDynamoDBHost(),
})

if err != nil {
Expand All @@ -90,7 +101,7 @@ func TestDynamoDBBackendStore(t *testing.T) {
backend := DynamoDBBackend{}

_ = backend.Init(map[string]string{
"endpoint": "http://dynamodb-local:8000",
"endpoint": getDynamoDBHost(),
"region": "ca-central-1",
"table_name": "secrets",
})
Expand All @@ -112,7 +123,7 @@ func TestDynamoDBBackendRetrieveWithTTLInFuture(t *testing.T) {
backend := DynamoDBBackend{}

_ = backend.Init(map[string]string{
"endpoint": "http://dynamodb-local:8000",
"endpoint": getDynamoDBHost(),
"region": "ca-central-1",
"table_name": "secrets",
})
Expand Down Expand Up @@ -144,7 +155,7 @@ func TestDynamoDBBackendRetrieveWithTTLInPast(t *testing.T) {
backend := DynamoDBBackend{}

_ = backend.Init(map[string]string{
"endpoint": "http://dynamodb-local:8000",
"endpoint": getDynamoDBHost(),
"region": "ca-central-1",
"table_name": "secrets",
})
Expand Down

0 comments on commit a86d79b

Please sign in to comment.