🚚 Renamed NewClientID to ParseClientID

This commit is contained in:
Maxim Lebedev 2022-01-29 19:45:49 +05:00
parent 2cc1fa02e7
commit c31d47d5ae
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
6 changed files with 10 additions and 10 deletions

View File

@ -26,7 +26,7 @@ var (
)
//nolint: funlen
func NewClientID(raw string) (*ClientID, error) {
func ParseClientID(raw string) (*ClientID, error) {
clientID := http.AcquireURI()
if err := clientID.Parse(nil, []byte(raw)); err != nil {
return nil, Error{
@ -113,7 +113,7 @@ func NewClientID(raw string) (*ClientID, error) {
func TestClientID(tb testing.TB) *ClientID {
tb.Helper()
clientID, err := NewClientID("https://app.example.com/")
clientID, err := ParseClientID("https://app.example.com/")
require.NoError(tb, err)
return clientID
@ -121,7 +121,7 @@ func TestClientID(tb testing.TB) *ClientID {
// UnmarshalForm implements a custom form.Unmarshaler.
func (cid *ClientID) UnmarshalForm(v []byte) error {
clientID, err := NewClientID(string(v))
clientID, err := ParseClientID(string(v))
if err != nil {
return fmt.Errorf("UnmarshalForm: %w", err)
}
@ -137,7 +137,7 @@ func (cid *ClientID) UnmarshalJSON(v []byte) error {
return err
}
clientID, err := NewClientID(src)
clientID, err := ParseClientID(src)
if err != nil {
return fmt.Errorf("UnmarshalJSON: %w", err)
}

View File

@ -10,7 +10,7 @@ import (
)
//nolint: funlen
func TestNewClientID(t *testing.T) {
func TestParseClientID(t *testing.T) {
t.Parallel()
for _, testCase := range []struct {
@ -67,7 +67,7 @@ func TestNewClientID(t *testing.T) {
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
result, err := domain.NewClientID(testCase.input)
result, err := domain.ParseClientID(testCase.input)
if testCase.isValid {
require.NoError(t, err)
assert.Equal(t, testCase.input, result.String())

View File

@ -126,7 +126,7 @@ func NewSession(src *domain.Session) *Session {
}
func (t *Session) Populate(dst *domain.Session) {
dst.ClientID, _ = domain.NewClientID(t.ClientID)
dst.ClientID, _ = domain.ParseClientID(t.ClientID)
dst.Code = t.Code
dst.CodeChallenge = t.CodeChallenge
dst.CodeChallengeMethod, _ = domain.ParseCodeChallengeMethod(t.CodeChallengeMethod)

View File

@ -90,7 +90,7 @@ func NewToken(src *domain.Token) *Token {
func (t *Token) Populate(dst *domain.Token) {
dst.AccessToken = t.AccessToken
dst.ClientID, _ = domain.NewClientID(t.ClientID)
dst.ClientID, _ = domain.ParseClientID(t.ClientID)
dst.Me, _ = domain.NewMe(t.Me)
dst.Scope = make(domain.Scopes, 0)

View File

@ -106,7 +106,7 @@ func (useCase *tokenUseCase) Verify(ctx context.Context, accessToken string) (*d
result := &domain.Token{
AccessToken: accessToken,
}
result.ClientID, _ = domain.NewClientID(t.Issuer())
result.ClientID, _ = domain.ParseClientID(t.Issuer())
result.Me, _ = domain.NewMe(t.Subject())
if scope, ok := t.Get("scope"); ok {

View File

@ -102,7 +102,7 @@ func init() {
rootURL := config.Server.GetRootURL()
client.Name = []string{config.Name}
if client.ID, err = domain.NewClientID(rootURL); err != nil {
if client.ID, err = domain.ParseClientID(rootURL); err != nil {
logger.Fatalln("fail to read config:", err)
}