Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPORT request at dates >30 with Mtime: "last month" pattern returns current month files #7629

Closed
saw-jan opened this issue Oct 31, 2023 · 4 comments · Fixed by #7742
Closed
Assignees
Labels

Comments

@saw-jan
Copy link
Member

saw-jan commented Oct 31, 2023

Description

If the date is 31 (or >30), searching with Mtime: "last month" query pattern gives files created this month NOT the files of previous month

Steps to reproduce

  1. Change system date to Oct 31
  2. Start ocis server
  3. Upload file with Sep 1 as mtime
    curl -XPUT "https://localhost:9200/remote.php/webdav/lastmonth.txt" \
    -H"X-OC-Mtime: 1693569600" -uadmin:admin
  4. Upload file with Oct 31 as mtime
    curl -XPUT "https://localhost:9200/remote.php/webdav/today.txt" \
    -H"X-OC-Mtime: 1698753600" -uadmin:admin
  5. Search with Mtime: "last month" pattern (:x: returns only current month files)
    curl -XREPORT "https://localhost:9200/remote.php/dav/spaces/<personal-space-id>" \
    -d "<?xml version='1.0' encoding='utf-8' ?>
    <oc:search-files xmlns:a='DAV:' xmlns:oc='http://owncloud.org/ns' >
      <oc:search>
        <oc:pattern>Mtime:\"last month\"</oc:pattern>
      </oc:search>
    </oc:search-files>" \
    -uadmin:admin
    <d:response>
      <d:href>/remote.php/dav/spaces/a02b1cfc-d8d3-4248-93e0-64e368e0e6c1$fb7821ab-f8a0-4e93-b8c2-005ebbc12* Connection #0 to host localhost left intact
    362/today.txt</d:href>
      <d:propstat>
        <d:prop>
          <oc:name>today.txt</oc:name>
          <d:getlastmodified>2023-10-31T12:00:00Z</d:getlastmodified>
          <d:getcontenttype>text/plain</d:getcontenttype>
        </d:prop>
      </d:propstat>
    </d:response>

Findings

When the date is 31: (same date range for both ❓)

  1. Mtime: "this month"
    Start: 63831694500 # Wednesday, September 30, 3992 12:00:00 AM GMT+05:45
    End: 63834372899 # Friday, October 30, 3992 11:59:59 PM GMT+05:45
  2. Mtime: "last month"
    Start: 63831694500 # Wednesday, September 30, 3992 12:00:00 AM GMT+05:45
    End: 63834372899 # Friday, October 30, 3992 11:59:59 PM GMT+05:45

When the date is NOT 31: (different date range for both ✔️)

  1. Mtime: "this month"
    Start: 63831694500 # Wednesday, September 30, 3992 12:00:00 AM GMT+05:45
    End: 63834372899 # Friday, October 30, 3992 11:59:59 PM GMT+05:45
  2. Mtime: "last month"
    Start: 63829102500 # Monday, August 31, 3992 12:00:00 AM GMT+05:45
    End: 63831694499 # Tuesday, September 29, 3992 11:59:59 PM GMT+05:45
Test Failure

DATE: Oct 31, 2023
CI: https://drone.owncloud.com/owncloud/ocis/28263/25/7

Scenario Outline: search resources using different search patterns (KQL feature) in the personal space                                                                 # /drone/src/tests/acceptance/features/apiSearch/dateSearch.feature:21
    Given user "Alice" uploads a file "filesForUpload/textfile.txt" to "/today.txt" with mtime "today" via TUS inside of the space "Personal" using the WebDAV API       # SpacesTUSContext::userUploadsAFileToWithMtimeViaTusInsideOfTheSpaceUsingTheWebdavApi()
    And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/yesterday.txt" with mtime "yesterday" via TUS inside of the space "Personal" using the WebDAV API # SpacesTUSContext::userUploadsAFileToWithMtimeViaTusInsideOfTheSpaceUsingTheWebdavApi()
    And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/lastWeek.txt" with mtime "lastWeek" via TUS inside of the space "Personal" using the WebDAV API   # SpacesTUSContext::userUploadsAFileToWithMtimeViaTusInsideOfTheSpaceUsingTheWebdavApi()
    And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/lastMonth.txt" with mtime "lastMonth" via TUS inside of the space "Personal" using the WebDAV API # SpacesTUSContext::userUploadsAFileToWithMtimeViaTusInsideOfTheSpaceUsingTheWebdavApi()
    And user "Alice" uploads a file "filesForUpload/textfile.txt" to "/lastYear.txt" with mtime "lastYear" via TUS inside of the space "Personal" using the WebDAV API   # SpacesTUSContext::userUploadsAFileToWithMtimeViaTusInsideOfTheSpaceUsingTheWebdavApi()
    And using spaces DAV path                                                                                                                                            # FeatureContext::usingOldOrNewDavPath()
    When user "Alice" searches for '<pattern>' using the WebDAV API                                                                                                      # SearchContext::userSearchesUsingWebDavAPI()
    Then the HTTP status code should be "207"                                                                                                                            # FeatureContext::thenTheHTTPStatusCodeShouldBe()
    And the search result of user "Alice" should contain these entries:                                                                                                  # FeatureContext::thePropfindResultShouldContainEntries()
      | <search-result-1> |
      | <search-result-2> |
    But the search result of user "Alice" should not contain these entries:                                                                                              # FeatureContext::thePropfindResultShouldContainEntries()
      | <search-result-3> |
      | <search-result-4> |

    Examples:
      | pattern            | search-result-1 | search-result-2 | search-result-3 | search-result-4 |
      | Mtime:today        | /today.txt      |                 | /yesterday.txt  | /lastWeek.txt   |
      | Mtime:yesterday    | /yesterday.txt  |                 | /today.txt      |                 |
      | Mtime:"this week"  | /today.txt      |                 | /lastWeek.txt   | /lastMont.txt   |
      | Mtime:"this month" | /today.txt      |                 | /lastMont.txt   |                 |
      | Mtime:"last month" | /lastMonth.txt  |                 | /today.txt      |                 |
        Failed step: But the search result of user "Alice" should not contain these entries:
        response does contain the entry '/today.txt' but should not
        Failed asserting that Array &0 (
            0 => SimpleXMLElement Object &000000004a7c430e000000001853932f (
                0 => 'today.txt'
            )
        ) is false.
==> REQUEST
REPORT /remote.php/dav/spaces/c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5
X-Request-ID: apiSearch/dateSearch.feature:42-28
==> REQ BODY
<?xml version='1.0' encoding='utf-8' ?>
<oc:search-files xmlns:a='DAV:' xmlns:oc='http://owncloud.org/ns' >
  <oc:search> 
    <oc:pattern>Mtime:"last month"</oc:pattern>
  </oc:search>
</oc:search-files>
RESPONSE
<== RESPONSE
207 Multi-Status
Transfer-Encoding: chunked
<== RES BODY
<d:multistatus
	xmlns:s="http://sabredav.org/ns"
	xmlns:d="DAV:"
	xmlns:oc="http://owncloud.org/ns">
  <d:response>
    <d:href>/remote.php/dav/spaces/c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5/lastMonth.txt</d:href>
    <d:propstat>
      <d:prop>
        <oc:fileid>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!28ea6a9e-2d63-4e6c-a3ff-db8d11c3b23f</oc:fileid>
        <oc:file-parent>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!6e857aa2-eaa7-4235-b999-934eac984ac5</oc:file-parent>
        <oc:name>lastMonth.txt</oc:name>
        <d:getlastmodified>2023-10-01T00:00:00Z</d:getlastmodified>
        <d:getcontenttype>text/plain</d:getcontenttype>
        <oc:permissions>RDNVW</oc:permissions>
        <oc:highlights></oc:highlights>
        <oc:tags></oc:tags>
        <d:getetag></d:getetag>
        <d:resourcetype></d:resourcetype>
        <d:getcontentlength>28</d:getcontentlength>
        <oc:score>2.2801826000213623</oc:score>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/spaces/c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5/today.txt</d:href>
    <d:propstat>
      <d:prop>
        <oc:fileid>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!d87d4efe-68df-47bd-b691-a0dde234a906</oc:fileid>
        <oc:file-parent>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!6e857aa2-eaa7-4235-b999-934eac984ac5</oc:file-parent>
        <oc:name>today.txt</oc:name>
        <d:getlastmodified>2023-10-31T00:00:00Z</d:getlastmodified>
        <d:getcontenttype>text/plain</d:getcontenttype>
        <oc:permissions>RDNVW</oc:permissions>
        <oc:highlights></oc:highlights>
        <oc:tags></oc:tags>
        <d:getetag></d:getetag>
        <d:resourcetype></d:resourcetype>
        <d:getcontentlength>28</d:getcontentlength>
        <oc:score>2.040480852127075</oc:score>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/spaces/c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5/yesterday.txt</d:href>
    <d:propstat>
      <d:prop>
        <oc:fileid>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!b3dfc698-4afe-497b-b2f3-be930198e392</oc:fileid>
        <oc:file-parent>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!6e857aa2-eaa7-4235-b999-934eac984ac5</oc:file-parent>
        <oc:name>yesterday.txt</oc:name>
        <d:getlastmodified>2023-10-30T00:00:00Z</d:getlastmodified>
        <d:getcontenttype>text/plain</d:getcontenttype>
        <oc:permissions>RDNVW</oc:permissions>
        <oc:highlights></oc:highlights>
        <oc:tags></oc:tags>
        <d:getetag></d:getetag>
        <d:resourcetype></d:resourcetype>
        <d:getcontentlength>28</d:getcontentlength>
        <oc:score>2.040480852127075</oc:score>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/spaces/c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5/lastWeek.txt</d:href>
    <d:propstat>
      <d:prop>
        <oc:fileid>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!d510ba2c-4b3c-4e37-9196-324e182bfd2e</oc:fileid>
        <oc:file-parent>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!6e857aa2-eaa7-4235-b999-934eac984ac5</oc:file-parent>
        <oc:name>lastWeek.txt</oc:name>
        <d:getlastmodified>2023-10-24T00:00:00Z</d:getlastmodified>
        <d:getcontenttype>text/plain</d:getcontenttype>
        <oc:permissions>RDNVW</oc:permissions>
        <oc:highlights></oc:highlights>
        <oc:tags></oc:tags>
        <d:getetag></d:getetag>
        <d:resourcetype></d:resourcetype>
        <d:getcontentlength>28</d:getcontentlength>
        <oc:score>2.040480852127075</oc:score>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/remote.php/dav/spaces/c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5</d:href>
    <d:propstat>
      <d:prop>
        <oc:fileid>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5!6e857aa2-eaa7-4235-b999-934eac984ac5</oc:fileid>
        <oc:file-parent>c72a6f6d-22f2-480b-8333-dd929b65cba8$6e857aa2-eaa7-4235-b999-934eac984ac5</oc:file-parent>
        <oc:name>Alice Hansen</oc:name>
        <d:getlastmodified>2023-10-31T06:31:12Z</d:getlastmodified>
        <d:getcontenttype>httpd/unix-directory</d:getcontenttype>
        <oc:permissions>RDNVCK</oc:permissions>
        <oc:highlights></oc:highlights>
        <oc:tags></oc:tags>
        <d:getetag></d:getetag>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>140</oc:size>
        <oc:score>1.9607993364334106</oc:score>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>
@saw-jan
Copy link
Member Author

saw-jan commented Oct 31, 2023

The log shows that the month for all files is 10 (Oct).

@saw-jan
Copy link
Member Author

saw-jan commented Oct 31, 2023

This could be due to the differences in timezone

@saw-jan
Copy link
Member Author

saw-jan commented Oct 31, 2023

search doesn't work properly with date 31 when using Mtime:"last month" search pattern?

CC @fschade @ScharfViktor

@saw-jan
Copy link
Member Author

saw-jan commented Oct 31, 2023

When the date is 31: (same date range for both ❓)

  1. Mtime: "this month"
    Start: 63831694500 # Wednesday, September 30, 3992 12:00:00 AM GMT+05:45
    End: 63834372899 # Friday, October 30, 3992 11:59:59 PM GMT+05:45
  2. Mtime: "last month"
    Start: 63831694500 # Wednesday, September 30, 3992 12:00:00 AM GMT+05:45
    End: 63834372899 # Friday, October 30, 3992 11:59:59 PM GMT+05:45

When the date is NOT 31: (different date range for both ✔️)

  1. Mtime: "this month"
    Start: 63831694500 # Wednesday, September 30, 3992 12:00:00 AM GMT+05:45
    End: 63834372899 # Friday, October 30, 3992 11:59:59 PM GMT+05:45
  2. Mtime: "last month"
    Start: 63829102500 # Monday, August 31, 3992 12:00:00 AM GMT+05:45
    End: 63831694499 # Tuesday, September 29, 3992 11:59:59 PM GMT+05:45

@saw-jan saw-jan changed the title [QA] APi test apiSearch/dateSearch.feature:42 is failing REPORT request at dates >30 with Mtime: "last month" pattern returns current month files Nov 1, 2023
@saw-jan saw-jan removed the QA:team label Nov 1, 2023
@2403905 2403905 self-assigned this Nov 7, 2023
@2403905 2403905 mentioned this issue Nov 16, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants