-
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.
- Loading branch information
Showing
18 changed files
with
340 additions
and
65 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 |
---|---|---|
|
@@ -16,7 +16,7 @@ jobs: | |
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20.x | ||
go-version: 1.21.x | ||
|
||
- name: Install Staticcheck | ||
run: go install honnef.co/go/tools/cmd/[email protected] | ||
|
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 |
---|---|---|
@@ -1,2 +1,17 @@ | ||
# courier | ||
A standalone certificate delivery service | ||
# Courier | ||
|
||
A stand-alone service that allows the GDS to deliver TRISA certificates via a webhook | ||
rather than email. The service accepts PCKS12 passwords and encrypted certificates from | ||
TRISA as HTTP `POST` requests and stores the certificates and passwords in either | ||
Google Secret Manager or on the local disk (other secret management backends such as | ||
Vault or Postgres may be available in the future). | ||
|
||
This tool is mostly used by TRISA Service Providers (TSPs) who have to handle many | ||
TRISA certificate deliveries at a time. VASPs who want to automate certificate delivery | ||
may also use this service. | ||
|
||
## Deploying with Docker | ||
|
||
The simplest way to run the courier service is to use the docker image | ||
`trisa/courier:latest` and to configure it from the environment. This allows the | ||
courier service to be easily run on a Kubernetes cluster. |
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
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,74 @@ | ||
package api_test | ||
|
||
import ( | ||
"errors" | ||
"net/http" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/trisacrypto/courier/pkg/api/v1" | ||
) | ||
|
||
func TestJoinStatusErrors(t *testing.T) { | ||
t.Run("Empty", func(t *testing.T) { | ||
err := api.JoinStatusErrors(0, 0, nil) | ||
require.NoError(t, err, "expected a nil error returned") | ||
|
||
err = api.JoinStatusErrors(0, 0, nil, nil, nil, nil, nil, nil) | ||
require.NoError(t, err, "expected a nil error returned for multiple nil errors") | ||
}) | ||
|
||
t.Run("SingleStatusError", func(t *testing.T) { | ||
err := api.JoinStatusErrors(1, 421*time.Millisecond, api.NewStatusError(http.StatusServiceUnavailable, "could not reach specified service")) | ||
require.Error(t, err, "expected error to be returned") | ||
|
||
serr, ok := err.(*api.StatusError) | ||
require.True(t, ok, "expected error to be a status error, not a multi status error") | ||
require.Equal(t, 503, serr.Code) | ||
}) | ||
|
||
t.Run("SingleError", func(t *testing.T) { | ||
err := api.JoinStatusErrors(1, 421*time.Millisecond, errors.New("something went wrong")) | ||
require.Error(t, err, "expected error to be returned") | ||
|
||
_, ok := err.(*api.StatusError) | ||
require.False(t, ok, "expected error to not be a status error") | ||
require.EqualError(t, err, "something went wrong") | ||
}) | ||
|
||
t.Run("MultiStatusErrors", func(t *testing.T) {}) | ||
|
||
t.Run("MultiErrors", func(t *testing.T) {}) | ||
|
||
t.Run("Mixed", func(t *testing.T) {}) | ||
|
||
t.Run("Deduplication", func(t *testing.T) {}) | ||
|
||
t.Run("MultiDeduplication", func(t *testing.T) {}) | ||
} | ||
|
||
func TestMultiStatusError(t *testing.T) { | ||
testCases := []struct { | ||
err *api.MultiStatusError | ||
expected string | ||
}{ | ||
{ | ||
&api.MultiStatusError{ | ||
Attempts: 1, | ||
Delay: 585 * time.Millisecond, | ||
Errs: []error{ | ||
&api.StatusError{ | ||
Code: http.StatusInternalServerError, | ||
Err: http.StatusText(http.StatusInternalServerError), | ||
}, | ||
}, | ||
}, | ||
"after 1 attempts: [500]: Internal Server Error", | ||
}, | ||
} | ||
|
||
for i, tc := range testCases { | ||
require.EqualError(t, tc.err, tc.expected, "test case %d failed", i) | ||
} | ||
} |
Oops, something went wrong.