Compare commits
No commits in common. "main" and "v0.8.3" have entirely different histories.
@ -193,12 +193,6 @@ type PrincipalBackend interface {
|
||||
ScheduleOutboxPath(ctx context.Context) (string, error)
|
||||
}
|
||||
|
||||
// PrincipalNameBackend is an optional Backend interface naming the current
|
||||
// user principal, served as its DAV:displayname.
|
||||
type PrincipalNameBackend interface {
|
||||
PrincipalDisplayName(ctx context.Context) (string, error)
|
||||
}
|
||||
|
||||
// FreeBusyBackend is an optional Backend interface answering free/busy
|
||||
// requests POSTed to the schedule outbox (RFC 6638 section 5). The Backend
|
||||
// must also implement PrincipalBackend.
|
||||
|
||||
@ -651,20 +651,8 @@ func (b *backend) propFindUserPrincipal(ctx context.Context, propfind *internal.
|
||||
calendarHomeSetName: internal.PropFindValue(&calendarHomeSet{
|
||||
Href: internal.Href{Path: homeSetPath},
|
||||
}),
|
||||
internal.PrincipalURLName: internal.PropFindValue(&internal.PrincipalURL{
|
||||
Href: internal.Href{Path: principalPath},
|
||||
}),
|
||||
internal.ResourceTypeName: internal.PropFindValue(internal.NewResourceType(internal.CollectionName, internal.PrincipalName)),
|
||||
}
|
||||
if nb, ok := b.Backend.(PrincipalNameBackend); ok {
|
||||
props[internal.DisplayNameName] = func(*internal.RawXMLValue) (interface{}, error) {
|
||||
name, err := nb.PrincipalDisplayName(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &internal.DisplayName{Name: name}, nil
|
||||
}
|
||||
}
|
||||
if pb, ok := b.Backend.(PrincipalBackend); ok {
|
||||
props[calendarUserAddressSetName] = func(*internal.RawXMLValue) (interface{}, error) {
|
||||
addrs, err := pb.CalendarUserAddresses(ctx)
|
||||
|
||||
@ -285,10 +285,6 @@ func (schedBackend) CalendarUserAddresses(ctx context.Context) ([]string, error)
|
||||
return []string{"wilfredo@example.com"}, nil
|
||||
}
|
||||
|
||||
func (schedBackend) PrincipalDisplayName(ctx context.Context) (string, error) {
|
||||
return "Wilfredo", nil
|
||||
}
|
||||
|
||||
func (schedBackend) ScheduleInboxPath(ctx context.Context) (string, error) {
|
||||
return "/user/inbox/", nil
|
||||
}
|
||||
@ -470,25 +466,6 @@ func TestPropFindPrincipalScheduling(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPropFindPrincipalNameAndURL(t *testing.T) {
|
||||
_, resp := serve(t, &Handler{Backend: schedBackend{}}, "PROPFIND", "/user/", "application/xml", `
|
||||
<d:propfind xmlns:d="DAV:"><d:prop><d:principal-URL/><d:displayname/></d:prop></d:propfind>`)
|
||||
for _, want := range []string{
|
||||
`<principal-URL xmlns="DAV:"><href>/user/</href></principal-URL>`,
|
||||
`<displayname xmlns="DAV:">Wilfredo</displayname>`,
|
||||
} {
|
||||
if !strings.Contains(resp, want) {
|
||||
t.Errorf("missing %s in response:\n%s", want, resp)
|
||||
}
|
||||
}
|
||||
|
||||
_, resp = serve(t, &Handler{Backend: testBackend{}}, "PROPFIND", "/user/", "application/xml", `
|
||||
<d:propfind xmlns:d="DAV:"><d:prop><d:principal-URL/><d:displayname/></d:prop></d:propfind>`)
|
||||
if !strings.Contains(resp, "principal-URL") || strings.Contains(resp, "Wilfredo") {
|
||||
t.Errorf("principal-URL is always served, displayname only with PrincipalNameBackend:\n%s", resp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOptionsAutoSchedule(t *testing.T) {
|
||||
res, _ := serve(t, &Handler{Backend: schedBackend{}}, http.MethodOptions, "/user/", "", "")
|
||||
if dav := res.Header.Get("DAV"); !strings.Contains(dav, "calendar-auto-schedule") {
|
||||
|
||||
@ -25,7 +25,6 @@ var (
|
||||
PrincipalName = xml.Name{Namespace, "principal"}
|
||||
|
||||
CurrentUserPrincipalName = xml.Name{Namespace, "current-user-principal"}
|
||||
PrincipalURLName = xml.Name{Namespace, "principal-URL"}
|
||||
CurrentUserPrivilegeSetName = xml.Name{Namespace, "current-user-privilege-set"}
|
||||
|
||||
SyncTokenName = xml.Name{Space: Namespace, Local: "sync-token"}
|
||||
@ -418,12 +417,6 @@ func (err *Error) Error() string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc3744#section-4.2
|
||||
type PrincipalURL struct {
|
||||
XMLName xml.Name `xml:"DAV: principal-URL"`
|
||||
Href Href `xml:"href"`
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc4918#section-15.2
|
||||
type DisplayName struct {
|
||||
XMLName xml.Name `xml:"DAV: displayname"`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user