-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recoverysigner: make allowed-source-account optional (#5052)
What This PR makes the --allowed-source-account flag optional. Why When ALLOWED_SOURCE_ACCOUNT is not specified or is empty, strings.Split(opts.AllowedSourceAccounts, ",") will return a slice containing an empty string. And we will get an error at keypair.ParseAddress(addressStr).
- Loading branch information
Showing
2 changed files
with
42 additions
and
5 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
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,35 @@ | ||
package serve | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stellar/go/keypair" | ||
supportlog "github.com/stellar/go/support/log" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"gopkg.in/square/go-jose.v2" | ||
) | ||
|
||
func TestGetHandlerDeps(t *testing.T) { | ||
signingKey := "SBWLXUTJR2CGVPGCZDIGGLQDPX7ZGGBHBFXBJ555MNIQ2PZCCLM643Z3" | ||
signingKeyFull := keypair.MustParseFull(signingKey) | ||
|
||
opts := Options{ | ||
Logger: supportlog.DefaultLogger, | ||
SigningKeys: signingKey, | ||
SEP10JWKS: `{"keys":[{"kty":"EC","crv":"P-256","alg":"ES256","x":"i8chX_7Slm4VQ_Y6XBWVBnxIO5-XSWH1GJsXWNkal3E","y":"G22r0OgrcQnkfCAqsS6wvtHgR0SbfvXNJy6-jJfvc94"}]}`, | ||
} | ||
|
||
sep10JWKS := jose.JSONWebKeySet{} | ||
err := json.Unmarshal([]byte(opts.SEP10JWKS), &sep10JWKS) | ||
require.NoError(t, err) | ||
|
||
got, err := getHandlerDeps(opts) | ||
assert.NoError(t, err) | ||
|
||
assert.Equal(t, []*keypair.Full{signingKeyFull}, got.SigningKeys) | ||
assert.Equal(t, []*keypair.FromAddress{signingKeyFull.FromAddress()}, got.SigningAddresses) | ||
assert.Equal(t, sep10JWKS, got.SEP10JWKS) | ||
assert.Equal(t, []*keypair.FromAddress{}, got.AllowedSourceAccounts) | ||
} |