_caldav__macOS_subscribe (private)

 _caldav__macOS_subscribe

Defined in packages/caldav/tcl/test/caldav-test-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_test::visualize_control_chars aa_test::visualize_control_chars aa_true aa_true (public) _caldav__macOS_subscribe _caldav__macOS_subscribe _caldav__macOS_subscribe->aa_equals _caldav__macOS_subscribe->aa_log _caldav__macOS_subscribe->aa_log_result _caldav__macOS_subscribe->aa_test::visualize_control_chars _caldav__macOS_subscribe->aa_true

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{

    set info [::caldav::test::basic_setup]
    set user_info [dict get $info user_info]

    try {
        #
        # 1. Query: principal-URL (Depth 0)
        #
        set queryNr 1
    set d [::acs::test::http -prefix "$queryNr: "  -user_info $user_info  -method PROPFIND  -headers {Content-Type text/xml Depth 0}  -body [::caldav::test::propfind_body "<D:principal-URL/>"]  /caldav/]
    aa_equals "Status code valid" [dict get $d status] 207
    set xml [dict get $d body]
    aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::non_empty $response {
                d:href
            }
            ::acs::test::xpath::equals $response {
                d:href                                       /caldav/
                d:propstat/d:prop/d:principal-URL            /caldav/principal
            }
        }

        #
        # 2. Query / multiple attributes (Depth 0)
        #
        incr queryNr
    set d [::acs::test::http -prefix "$queryNr: "  -user_info $user_info  -method PROPFIND  -headers {Content-Type text/xml Depth 0}  -body {<?xml version="1.0" encoding="UTF-8"?>
                       <A:propfind xmlns:A="DAV:">
                       <A:prop>
                       <C:calendar-home-set xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <C:calendar-user-address-set xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <A:current-user-principal/>
                       <A:displayname/>
                       <E:dropbox-home-URL xmlns:E="http://calendarserver.org/ns/"/>
                       <E:email-address-set xmlns:E="http://calendarserver.org/ns/"/>
                       <E:notification-URL xmlns:E="http://calendarserver.org/ns/"/>
                       <A:principal-collection-set/>
                       <A:principal-URL/>
                       <A:resource-id/>
                       <C:schedule-inbox-URL xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <C:schedule-outbox-URL xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <A:supported-report-set/>
                       </A:prop>
                       </A:propfind>}  /caldav/]
    aa_equals "Status code valid" [dict get $d status] 207
    set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::non_empty $response {
                d:href
            }
            ::acs::test::xpath::equals $response {
                d:href                                       /caldav/
                d:propstat/d:prop/c:calendar-home-set        /caldav/calendar
                d:propstat/d:prop/d:current-user-principal   /caldav/principal
                d:propstat/d:prop/d:principal-URL            /caldav/principal
            }
        }
        #
        # OPTIONS request
        # .... omitted here
        #
        # 3. Query on calendar (Depth 1)
        #
        incr queryNr
    set d [::acs::test::http -prefix "$queryNr: "  -user_info $user_info  -method PROPFIND  -headers {Content-Type text/xml Depth 1}  -body {<?xml version="1.0" encoding="UTF-8"?>
                       <A:propfind xmlns:A="DAV:">
                       <A:prop>
                       <A:add-member/>
                       <E:allowed-sharing-modes xmlns:E="http://calendarserver.org/ns/"/>
                       <F:autoprovisioned xmlns:F="http://apple.com/ns/ical/"/>
                       <G:bulk-requests xmlns:G="http://me.com/_namespace/"/>
                       <C:calendar-alarm xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <F:calendar-color xmlns:F="http://apple.com/ns/ical/"/>
                       <C:calendar-description xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <C:calendar-free-busy-set xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <F:calendar-order xmlns:F="http://apple.com/ns/ical/"/>
                       <C:calendar-timezone xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <A:current-user-privilege-set/>
                       <C:default-alarm-vevent-date xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <C:default-alarm-vevent-datetime xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <A:displayname/>
                       <E:getctag xmlns:E="http://calendarserver.org/ns/"/>
                       <E:invite xmlns:E="http://calendarserver.org/ns/"/>
                       <F:language-code xmlns:F="http://apple.com/ns/ical/"/>
                       <F:location-code xmlns:F="http://apple.com/ns/ical/"/>
                       <A:owner/>
                       <E:pre-publish-url xmlns:E="http://calendarserver.org/ns/"/>
                       <E:publish-url xmlns:E="http://calendarserver.org/ns/"/>
                       <E:push-transports xmlns:E="http://calendarserver.org/ns/"/>
                       <E:pushkey xmlns:E="http://calendarserver.org/ns/"/>
                       <A:quota-available-bytes/>
                       <A:quota-used-bytes/>
                       <F:refreshrate xmlns:F="http://apple.com/ns/ical/"/>
                       <A:resource-id/>
                       <A:resourcetype/>
                       <C:schedule-calendar-transp xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <C:schedule-default-calendar-URL xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <E:source xmlns:E="http://calendarserver.org/ns/"/>
                       <E:subscribed-strip-alarms xmlns:E="http://calendarserver.org/ns/"/>
                       <E:subscribed-strip-attachments xmlns:E="http://calendarserver.org/ns/"/>
                       <E:subscribed-strip-todos xmlns:E="http://calendarserver.org/ns/"/>
                       <C:supported-calendar-component-set xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <C:supported-calendar-component-sets xmlns:C="urn:ietf:params:xml:ns:caldav"/>
                       <A:supported-report-set/>
                       <A:sync-token/>
                       </A:prop>
                       </A:propfind>}  /caldav/calendar]
    aa_equals "Status code valid" [dict get $d status] 207
    set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::non_empty $response {
                d:href
                d:propstat/d:prop/c:calendar-description
                d:propstat/d:prop/d:displayname
                d:propstat/d:prop/cs:getctag
            }
            ::acs::test::xpath::equals $response {
                d:href                                       /caldav/calendar/
                d:propstat/d:prop/ical:calendar-order        1
            }
        }

        #
        # 4. Query PROPPATCH setting default-alarm-vevent-date
        # Note the encoded CRs for XML.
        incr queryNr

        set ical ""
        append ical  {BEGIN:VALARM&#13;} \n {X-WR-ALARMUID:3DC5B1FB-C20F-4DD1-AF41-06DF92E4C2A4&#13;} \n {UID:3DC5B1FB-C20F-4DD1-AF41-06DF92E4C2A4&#13;} \n {TRIGGER:-PT15H&#13;} \n {ATTACH;VALUE=URI:Basso&#13;} \n {ACTION:AUDIO&#13;} \n {END:VALARM&#13;} \n
        set d [::caldav::test::proppatch  -prefix "$queryNr: "  -user_info $user_info  /caldav/calendar default-alarm-vevent-date $ical]
    set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::equals $response {
                d:href                 /caldav/calendar
                d:propstat/d:status    "HTTP/1.1 403 Forbidden"
            }
        }

        #
        # 5. Query PROPPATCH setting default-alarm-vevent-datetime
        # Note the encoded CRs for XML.
        incr queryNr

        set ical ""
        append ical  {BEGIN:VALARM&#13;} \n {X-WR-ALARMUID:41C0F75E-720F-427B-8F9F-49EDF69DB760&#13;} \n {UID:41C0F75E-720F-427B-8F9F-49EDF69DB760&#13;} \n {TRIGGER;VALUE=DATE-TIME:19760401T005545Z#13;} \n {ATTACH;VALUE=URI:Basso&#13;} \n {ACTION:NONE&#13;} \n {END:VALARM&#13;} \n

        set d [::caldav::test::proppatch  -user_info $user_info  -prefix "$queryNr: "  /caldav/calendar default-alarm-vevent-datetime $ical]
    set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::equals $response {
                d:href                 /caldav/calendar
                d:propstat/d:status    "HTTP/1.1 403 Forbidden"
            }
        }

        #
        # 6. Query PROPPATCH setting calendar-timezone
        # Note the encoded CRs for XML.
        incr queryNr

        set ical ""
        append ical  {BEGIN:VCALENDAR&#13;} \n {VERSION:2.0&#13;} \n {PRODID:-//Apple Inc.//macOS 10.13.3//EN&#13;} \n {CALSCALE:GREGORIAN&#13;} \n {BEGIN:VTIMEZONE&#13;} \n {TZID:Europe/Vienna&#13;} \n {BEGIN:DAYLIGHT&#13;} \n {TZOFFSETFROM:+0100&#13;} \n {RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU&#13;} \n {DTSTART:19810329T020000&#13;} \n {TZNAME:GMT+2&#13;} \n {TZOFFSETTO:+0200&#13;} \n {END:DAYLIGHT&#13;} \n {BEGIN:STANDARD&#13;} \n {TZOFFSETFROM:+0200&#13;} \n {RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU&#13;} \n {DTSTART:19961027T030000&#13;} \n {TZNAME:GMT+1&#13;} \n {TZOFFSETTO:+0100&#13;} \n {END:STANDARD&#13;} \n {END:VTIMEZONE&#13;} \n {END:VCALENDAR&#13;} \n

        set d [::caldav::test::proppatch  -user_info $user_info  -prefix "$queryNr: "  /caldav/calendar calendar-timezone $ical]
    set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::equals $response {
                d:href                 /caldav/calendar
                d:propstat/d:status    "HTTP/1.1 403 Forbidden"
            }
        }

        #
        # 7. Query PROPFIND for sync-token or getctag with Depth 0
        #
        incr queryNr

        set XMLquery {<E:getctag xmlns:E="http://calendarserver.org/ns/"/><D:sync-token/>}
    set d [::acs::test::http  -prefix "$queryNr: "  -user_info $user_info  -method PROPFIND  -headers {Content-Type text/xml Depth 0}  -body [::caldav::test::propfind_body $XMLquery]  /caldav/calendar]
    aa_equals "Status code valid" [dict get $d status] 207
        set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::equals $response {
                d:href                          /caldav/calendar/
                d:propstat/d:prop/d:sync-token  ""
            }
            ::acs::test::xpath::non_empty $response {
                d:propstat/d:prop/cs:getctag
            }
        }

        #
    # 8. Query REPORT for etags and getcontenttype
        # TODO: filter + calendar-query guessed, has to corrected for macOS client
        #
        incr queryNr

    set d [::acs::test::http -prefix "$queryNr: "  -user_info $user_info  -method REPORT  -headers {Content-Type text/xml}  -body {<?xml version="1.0" encoding="UTF-8"?>
                       <B:calendar-query xmlns:B="urn:ietf:params:xml:ns:caldav">
                       <A:prop xmlns:A="DAV:">
                       <A:getetag/>
                       <A:getcontenttype/>
                       </A:prop>
                       <B:filter>
                       <B:comp-filter name="VCALENDAR">
                       <B:comp-filter name="VEVENT">
                       <B:time-range start="20180221T000000Z"/>
                       </B:comp-filter>
                       </B:comp-filter>
                       </B:filter>
                       </B:calendar-query>
           }  /caldav/calendar/]

    aa_equals "Status code valid" [dict get $d status] 207
    set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::non_empty $response {
                d:href
                d:propstat/d:prop/d:getetag
                d:propstat/d:prop/d:getcontenttype
            }
            set href [::acs::test::xpath::get_text $response d:href]
            aa_true "href for calitem ends with .ics" [string match *ics $href]
        }

    # 9. Query REPORT for etags and calendar-data
        # TODO: filter + calendar-query guessed, has to corrected for macOS client
        #
        incr queryNr

    set d [::acs::test::http -prefix "$queryNr: "  -user_info $user_info  -method REPORT  -headers {Content-Type text/xml}  -body {<?xml version="1.0" encoding="UTF-8"?>
                       <B:calendar-query xmlns:B="urn:ietf:params:xml:ns:caldav">
                       <A:prop xmlns:A="DAV:">
                       <A:getetag/>
                       <B:calendar-data/>
                       </A:prop>
                       <B:filter>
                       <B:comp-filter name="VCALENDAR">
                       <B:comp-filter name="VEVENT">
                       <B:time-range start="20180221T000000Z"/>
                       </B:comp-filter>
                       </B:comp-filter>
                       </B:filter>
                       </B:calendar-query>
           }  /caldav/calendar/]

    aa_equals "Status code valid" [dict get $d status] 207
    set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::non_empty $response {
                d:href
                d:propstat/d:prop/d:getetag
                d:propstat/d:prop/c:calendar-data
            }
            set href [::acs::test::xpath::get_text $response d:href]
            set icalText [::acs::test::xpath::get_text $response d:propstat/d:prop/c:calendar-data]
            #aa_log CHECK=[::aa_test::visualize_control_chars $icalText]

            aa_true "href for calitem ends with .ics" [string match *ics $href]
            aa_equals "Ical of $href valid" [::caldav::test::ical_valid -require_crlf=0 $icalText""
        }

        #
        # 10. Query PROPFIND for checksum-versions with Depth 0
        # .... not clear what it can return, all checked clients ignore this
        #
        incr queryNr

        set XMLquery {<E:checksum-versions xmlns:E="http://calendarserver.org/ns/"/>}
    set d [::acs::test::http -prefix "$queryNr: "  -user_info $user_info  -method PROPFIND  -headers {Content-Type text/xml Depth 0}  -body [::caldav::test::propfind_body $XMLquery]  /caldav/calendar]
    aa_equals "Status code valid" [dict get $d status] 207
        set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        #
        # 11. Query PROPFIND for getctag with Depth 0
        #
        incr queryNr

        set XMLquery {<E:getctag xmlns:E="http://calendarserver.org/ns/"/>}
    set d [::acs::test::http -prefix "$queryNr: "  -user_info $user_info  -method PROPFIND  -headers {Content-Type text/xml Depth 0}  -body [::caldav::test::propfind_body $XMLquery]  /caldav/calendar]
    aa_equals "Status code valid" [dict get $d status] 207
        set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        ::caldav::test::foreach_response response $xml {
            ::acs::test::xpath::equals $response {
                d:href                          /caldav/calendar/
            }
            ::acs::test::xpath::non_empty $response {
                d:propstat/d:prop/cs:getctag
            }
        }

        #
        # 12. Query PROPFIND for etag and contenttype Depth 1
        #
        incr queryNr

    set d [::acs::test::http -prefix "$queryNr: "  -user_info $user_info  -method PROPFIND  -headers {Content-Type text/xml Depth 1}  -body [::caldav::test::propfind_body "<D:getcontenttype/><D:getetag/>"]  /caldav/calendar]
    aa_equals "Status code valid" [dict get $d status] 207
        set xml [dict get $d body]
        aa_log "Result body:<pre>\n[::aa_test::visualize_control_chars $xml]</pre>"

        set nrEtags 0
        ::caldav::test::foreach_response response $xml {
            set href [::acs::test::xpath::get_text $response d:href]
            if {[string match *.ics $href]} {
                ::acs::test::xpath::non_empty $response {
                    d:propstat/d:prop/d:getetag
                    d:propstat/d:prop/d:getcontenttype
                }
                incr nrEtags
            }
        }
        aa_true "Got multiple etags: $nrEtags" {$nrEtags >= 3}

    } on error {errorMsg} {
    aa_true "Error msg: $errorMsg" 0
    } finally {
    #calendar::delete -calendar_id $temp_calendar_id
    }
}} {
          aa_log "Running testcase body $body_count"
          set ::__aa_test_indent [info level]
          set catch_val [catch $testcase_body msg]
          if {$catch_val != 0 && $catch_val != 2} {
              aa_log_result "fail" "macOS_subscribe (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: