github.com/cs3org/reva/v2@v2.27.7/internal/http/services/owncloud/ocdav/report_test.go (about) 1 // Copyright 2018-2021 CERN 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // In applying this license, CERN does not waive the privileges and immunities 16 // granted to it by virtue of its status as an Intergovernmental Organization 17 // or submit itself to any jurisdiction. 18 19 package ocdav 20 21 import ( 22 "strings" 23 "testing" 24 ) 25 26 func TestUnmarshallReportFilterFiles(t *testing.T) { 27 ffXML := `<oc:filter-files xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"> 28 <d:prop> 29 <d:getlastmodified /> 30 <d:getetag /> 31 <d:getcontenttype /> 32 <d:resourcetype /> 33 <oc:fileid /> 34 <oc:permissions /> 35 <oc:size /> 36 <d:getcontentlength /> 37 <oc:tags /> 38 <oc:favorite /> 39 <d:lockdiscovery /> 40 <oc:comments-unread /> 41 <oc:owner-display-name /> 42 <oc:share-types /> 43 </d:prop> 44 <oc:filter-rules> 45 <oc:favorite>1</oc:favorite> 46 </oc:filter-rules> 47 </oc:filter-files>` 48 49 reader := strings.NewReader(ffXML) 50 51 report, status, err := readReport(reader) 52 if status != 0 || err != nil { 53 t.Error("Failed to unmarshal filter-files xml") 54 } 55 56 if report.FilterFiles == nil { 57 t.Error("Failed to unmarshal filter-files xml. FilterFiles is nil") 58 } 59 60 if report.FilterFiles.Rules.Favorite == false { 61 t.Error("Failed to correctly unmarshal filter-rules. Favorite is expected to be true.") 62 } 63 }