-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #236 Initial refactor * #236 Work in progress * #236 Move from localhost to 0.0.0.0 * #236 Working server-side TLS * #236 Update dependencies * #236 Savepoint * #236 Fix expected output * #236 Savepoint * #236 Savepoint * #236 Savepoint * #236 Add TLS testing * #236 Add os env vars * #236 Add os env vars * #236 Add os env vars - 3 * #236 Add os env vars - 4 * #236 Add os env vars - 5 * #236 Add os env vars - 6 * #236 Savepoint * #236 mount /testdata * #236 use github.workspace * #236 Fix lint issue * #236 docker restart * #236 Use ./testdata * #236 Debug docker container - 1 * #236 Debug docker container - 2 * #236 Debug docker container - 3 * #236 Debug docker container - 4 * #236 Debug docker container - 5 * #236 Debug docker container - 6 * #236 Debug docker container - 7 * #236 Debug docker container - 8 * #236 Debug docker container - 9 * #236 Debug docker container - 10 * #236 Debug docker container - 12 * #236 Debug docker container - 13 * #236 Debug docker container - 14 * #236 Debug docker container - 15 * #236 Debug docker container - 16 * #236 Working TLS testing - 17 * #236 docker login via step * #236 Update dependencies
- Loading branch information
Showing
32 changed files
with
735 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Go test linux - server-side TLS | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
env: | ||
SENZING_LOG_LEVEL: TRACE | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
go-test-linux: | ||
name: "Go test with OS: ${{ matrix.os }}; Go: ${{ matrix.go }}" | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
go: ["1.21"] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | ||
|
||
- name: Docker run | ||
run: | | ||
docker run \ | ||
--detach \ | ||
--env SENZING_TOOLS_ENABLE_ALL=true \ | ||
--env SENZING_TOOLS_SERVER_CERTIFICATE_PATH=/testdata/certificates/server/certificate.pem \ | ||
--env SENZING_TOOLS_SERVER_KEY_PATH=/testdata/certificates/server/private_key.pem \ | ||
--name servegrpc \ | ||
--publish 8261:8261 \ | ||
--rm \ | ||
--user 0 \ | ||
--volume ${{ github.workspace }}/testdata:/testdata \ | ||
senzing/serve-grpc | ||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: Set up gotestfmt | ||
uses: gotesttools/gotestfmt-action@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Run go test | ||
env: | ||
SENZING_TOOLS_CA_CERTIFICATE_PATH: ${{ github.workspace }}/testdata/certificates/certificate-authority/certificate.pem | ||
run: go test -json -v -p 1 -coverprofile=./cover.out -covermode=atomic -coverpkg=./... ./... 2>&1 | tee /tmp/gotest.log | gotestfmt | ||
|
||
- name: Store coverage file | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cover.out | ||
path: ./cover.out | ||
|
||
- name: Upload test log | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: test-log | ||
path: /tmp/gotest.log | ||
if-no-files-found: error | ||
|
||
coverage: | ||
name: Coverage | ||
needs: go-test-linux | ||
uses: senzing-factory/build-resources/.github/workflows/go-coverage.yaml@v2 | ||
with: | ||
coverage-config: ./.github/coverage/testcoverage.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package helper | ||
|
||
import ( | ||
"crypto/tls" | ||
"crypto/x509" | ||
"fmt" | ||
"os" | ||
|
||
"google.golang.org/grpc/credentials" | ||
"google.golang.org/grpc/credentials/insecure" | ||
) | ||
|
||
/* | ||
The GetGrpcTransportCredentials function returns a gRPC credentials.TransportCredentials | ||
based on the value of the value of the SENZING_TOOLS_CA_CERTIFICATE_PATH OS environment variable. | ||
If the environment variable does not exist, an insecure transport credential is returned. | ||
Output | ||
- Transport Credential calculated by OS environment variables. | ||
*/ | ||
func GetGrpcTransportCredentials() (credentials.TransportCredentials, error) { | ||
var result credentials.TransportCredentials | ||
certFile, isSet := os.LookupEnv("SENZING_TOOLS_CA_CERTIFICATE_PATH") | ||
if isSet { | ||
pemServerCA, err := os.ReadFile(certFile) | ||
if err != nil { | ||
return result, err | ||
} | ||
certPool := x509.NewCertPool() | ||
if !certPool.AppendCertsFromPEM(pemServerCA) { | ||
return result, fmt.Errorf("failed to add server CA's certificate") | ||
} | ||
config := &tls.Config{ | ||
RootCAs: certPool, | ||
MinVersion: tls.VersionTLS12, // See https://pkg.go.dev/crypto/tls#pkg-constants | ||
MaxVersion: tls.VersionTLS13, | ||
} | ||
result = credentials.NewTLS(config) | ||
} else { | ||
result = insecure.NewCredentials() | ||
} | ||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package helper | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Interface methods - test | ||
// ---------------------------------------------------------------------------- | ||
|
||
func TestHelpers_GetGrpcTransportCredentials_ServerSideTLS(test *testing.T) { | ||
envVar := "SENZING_TOOLS_CA_CERTIFICATE_PATH" | ||
_, isSet := os.LookupEnv(envVar) | ||
if !isSet { | ||
os.Setenv(envVar, "../testdata/certificates/certificate-authority/certificate.pem") | ||
defer os.Unsetenv(envVar) | ||
} | ||
actual, err := GetGrpcTransportCredentials() | ||
require.NoError(test, err) | ||
assert.NotEmpty(test, actual) | ||
} | ||
|
||
func TestHelpers_GetGrpcTransportCredentials_Insecure(test *testing.T) { | ||
envVar := "SENZING_TOOLS_CA_CERTIFICATE_PATH" | ||
value, isSet := os.LookupEnv(envVar) | ||
if isSet { | ||
os.Unsetenv(envVar) | ||
defer os.Setenv(envVar, value) | ||
} | ||
actual, err := GetGrpcTransportCredentials() | ||
require.NoError(test, err) | ||
assert.Empty(test, actual) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.