🚚 Renamed NewMe to ParseMe
This commit is contained in:
parent
c31d47d5ae
commit
7ce8335212
|
@ -19,7 +19,7 @@ type Me struct {
|
|||
}
|
||||
|
||||
//nolint: funlen
|
||||
func NewMe(raw string) (*Me, error) {
|
||||
func ParseMe(raw string) (*Me, error) {
|
||||
me := http.AcquireURI()
|
||||
if err := me.Parse(nil, []byte(raw)); err != nil {
|
||||
return nil, Error{
|
||||
|
@ -104,7 +104,7 @@ func NewMe(raw string) (*Me, error) {
|
|||
func TestMe(tb testing.TB, src string) *Me {
|
||||
tb.Helper()
|
||||
|
||||
me, err := NewMe(src)
|
||||
me, err := ParseMe(src)
|
||||
require.NoError(tb, err)
|
||||
|
||||
return me
|
||||
|
@ -112,7 +112,7 @@ func TestMe(tb testing.TB, src string) *Me {
|
|||
|
||||
// UnmarshalForm parses the value of the form key into the Me domain.
|
||||
func (m *Me) UnmarshalForm(v []byte) error {
|
||||
me, err := NewMe(string(v))
|
||||
me, err := ParseMe(string(v))
|
||||
if err != nil {
|
||||
return fmt.Errorf("UnmarshalForm: %w", err)
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ func (m *Me) UnmarshalJSON(v []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
me, err := NewMe(src)
|
||||
me, err := ParseMe(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("UnmarshalForm: %w", err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
//nolint: funlen
|
||||
func TestNewMe(t *testing.T) {
|
||||
func TestParseMe(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, testCase := range []struct {
|
||||
|
@ -63,7 +63,7 @@ func TestNewMe(t *testing.T) {
|
|||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
result, err := domain.NewMe(testCase.input)
|
||||
result, err := domain.ParseMe(testCase.input)
|
||||
if testCase.isValid {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, testCase.input, result.String())
|
||||
|
|
|
@ -130,7 +130,7 @@ func (t *Session) Populate(dst *domain.Session) {
|
|||
dst.Code = t.Code
|
||||
dst.CodeChallenge = t.CodeChallenge
|
||||
dst.CodeChallengeMethod, _ = domain.ParseCodeChallengeMethod(t.CodeChallengeMethod)
|
||||
dst.Me, _ = domain.NewMe(t.Me)
|
||||
dst.Me, _ = domain.ParseMe(t.Me)
|
||||
dst.RedirectURI, _ = domain.NewURL(t.RedirectURI)
|
||||
|
||||
for _, scope := range strings.Fields(t.Scope) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
type (
|
||||
GenerateRequest struct {
|
||||
// The access token should be used when acting on behalf of this URL.
|
||||
Subject *domain.URL `form:"subject"`
|
||||
Subject *domain.Me `form:"subject"`
|
||||
|
||||
// The access token will work at this URL.
|
||||
Resource *domain.URL `form:"resource"`
|
||||
|
@ -34,7 +34,7 @@ type (
|
|||
Ticket string `form:"ticket"`
|
||||
|
||||
// The access token should be used when acting on behalf of this URL.
|
||||
Subject *domain.URL `form:"subject"`
|
||||
Subject *domain.Me `form:"subject"`
|
||||
|
||||
// The access token will work at this URL.
|
||||
Resource *domain.URL `form:"resource"`
|
||||
|
|
|
@ -114,6 +114,6 @@ func NewTicket(src *domain.Ticket) *Ticket {
|
|||
|
||||
func (t *Ticket) Populate(dst *domain.Ticket) {
|
||||
dst.Ticket = t.Ticket
|
||||
dst.Subject, _ = domain.NewURL(t.Subject)
|
||||
dst.Subject, _ = domain.ParseMe(t.Subject)
|
||||
dst.Resource, _ = domain.NewURL(t.Resource)
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ func NewToken(src *domain.Token) *Token {
|
|||
func (t *Token) Populate(dst *domain.Token) {
|
||||
dst.AccessToken = t.AccessToken
|
||||
dst.ClientID, _ = domain.ParseClientID(t.ClientID)
|
||||
dst.Me, _ = domain.NewMe(t.Me)
|
||||
dst.Me, _ = domain.ParseMe(t.Me)
|
||||
dst.Scope = make(domain.Scopes, 0)
|
||||
|
||||
for _, scope := range strings.Fields(t.Scope) {
|
||||
|
|
|
@ -107,7 +107,7 @@ func (useCase *tokenUseCase) Verify(ctx context.Context, accessToken string) (*d
|
|||
AccessToken: accessToken,
|
||||
}
|
||||
result.ClientID, _ = domain.ParseClientID(t.Issuer())
|
||||
result.Me, _ = domain.NewMe(t.Subject())
|
||||
result.Me, _ = domain.ParseMe(t.Subject())
|
||||
|
||||
if scope, ok := t.Get("scope"); ok {
|
||||
result.Scope, _ = scope.(domain.Scopes)
|
||||
|
|
|
@ -53,7 +53,7 @@ func (repo *httpUserRepository) Get(ctx context.Context, me *domain.Me) (*domain
|
|||
}
|
||||
|
||||
// TODO(toby3d): handle error here?
|
||||
resolvedMe, _ := domain.NewMe(string(resp.Header.Peek(http.HeaderLocation)))
|
||||
resolvedMe, _ := domain.ParseMe(string(resp.Header.Peek(http.HeaderLocation)))
|
||||
u := &domain.User{
|
||||
Me: resolvedMe,
|
||||
Profile: &domain.Profile{
|
||||
|
|
Loading…
Reference in New Issue