From 4ad8eef9c62c7c40a4d5aad799cfed034bf35e35 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Sat, 8 Feb 2020 21:25:04 +0100
Subject: [PATCH] cmis: add a test that mock http requests (#39597)

---
 tests/data/cmis/cmis1.out.xml | 178 ++++++++++++++++++++++++++++++++++
 tests/data/cmis/cmis2.out.xml |  60 ++++++++++++
 tests/data/cmis/cmis3.in.xml  |  18 ++++
 tests/data/cmis/cmis3.out.xml |  91 +++++++++++++++++
 tests/test_cmis.py            |  48 +++++++++
 5 files changed, 395 insertions(+)
 create mode 100644 tests/data/cmis/cmis1.out.xml
 create mode 100644 tests/data/cmis/cmis2.out.xml
 create mode 100644 tests/data/cmis/cmis3.in.xml
 create mode 100644 tests/data/cmis/cmis3.out.xml

diff --git a/tests/data/cmis/cmis1.out.xml b/tests/data/cmis/cmis1.out.xml
new file mode 100644
index 00000000..f92e05b0
--- /dev/null
+++ b/tests/data/cmis/cmis1.out.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<app:service xmlns:atom="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:app="http://www.w3.org/2007/app">
+  <app:workspace>
+    <atom:title>test</atom:title>
+    <app:collection href="http://example.com/cmisatom/test/children?id=%40root%40">
+      <cmisra:collectionType>root</cmisra:collectionType>
+      <atom:title type="text">Root Collection</atom:title>
+      <app:accept>application/atom+xml;type=entry</app:accept>
+      <app:accept>application/cmisatom+xml</app:accept>
+    </app:collection>
+    <app:collection href="http://example.com/cmisatom/test/types">
+      <cmisra:collectionType>types</cmisra:collectionType>
+      <atom:title type="text">Types Collection</atom:title>
+      <app:accept/>
+    </app:collection>
+    <app:collection href="http://example.com/cmisatom/test/checkedout">
+      <cmisra:collectionType>checkedout</cmisra:collectionType>
+      <atom:title type="text">Checked Out Collection</atom:title>
+      <app:accept>application/cmisatom+xml</app:accept>
+    </app:collection>
+    <app:collection href="http://example.com/cmisatom/test/update">
+      <cmisra:collectionType>update</cmisra:collectionType>
+      <atom:title type="text">Bulk Update Collection</atom:title>
+      <app:accept>application/cmisatom+xml</app:accept>
+    </app:collection>
+    <cmisra:repositoryInfo>
+      <cmis:repositoryId>test</cmis:repositoryId>
+      <cmis:repositoryName>test</cmis:repositoryName>
+      <cmis:repositoryDescription>test</cmis:repositoryDescription>
+      <cmis:vendorName>OpenCMIS</cmis:vendorName>
+      <cmis:productName>OpenCMIS FileShare</cmis:productName>
+      <cmis:productVersion>1.1.0</cmis:productVersion>
+      <cmis:rootFolderId>@root@</cmis:rootFolderId>
+      <cmis:capabilities>
+        <cmis:capabilityACL>discover</cmis:capabilityACL>
+        <cmis:capabilityAllVersionsSearchable>false</cmis:capabilityAllVersionsSearchable>
+        <cmis:capabilityChanges>none</cmis:capabilityChanges>
+        <cmis:capabilityContentStreamUpdatability>anytime</cmis:capabilityContentStreamUpdatability>
+        <cmis:capabilityGetDescendants>true</cmis:capabilityGetDescendants>
+        <cmis:capabilityGetFolderTree>true</cmis:capabilityGetFolderTree>
+        <cmis:capabilityOrderBy>common</cmis:capabilityOrderBy>
+        <cmis:capabilityMultifiling>false</cmis:capabilityMultifiling>
+        <cmis:capabilityPWCSearchable>false</cmis:capabilityPWCSearchable>
+        <cmis:capabilityPWCUpdatable>false</cmis:capabilityPWCUpdatable>
+        <cmis:capabilityQuery>none</cmis:capabilityQuery>
+        <cmis:capabilityRenditions>none</cmis:capabilityRenditions>
+        <cmis:capabilityUnfiling>false</cmis:capabilityUnfiling>
+        <cmis:capabilityVersionSpecificFiling>false</cmis:capabilityVersionSpecificFiling>
+        <cmis:capabilityJoin>none</cmis:capabilityJoin>
+        <cmis:capabilityCreatablePropertyTypes/>
+        <cmis:capabilityNewTypeSettableAttributes>
+          <cmis:id>false</cmis:id>
+          <cmis:localName>false</cmis:localName>
+          <cmis:localNamespace>false</cmis:localNamespace>
+          <cmis:displayName>false</cmis:displayName>
+          <cmis:queryName>false</cmis:queryName>
+          <cmis:description>false</cmis:description>
+          <cmis:creatable>false</cmis:creatable>
+          <cmis:fileable>false</cmis:fileable>
+          <cmis:queryable>false</cmis:queryable>
+          <cmis:fulltextIndexed>false</cmis:fulltextIndexed>
+          <cmis:includedInSupertypeQuery>false</cmis:includedInSupertypeQuery>
+          <cmis:controllablePolicy>false</cmis:controllablePolicy>
+          <cmis:controllableACL>false</cmis:controllableACL>
+        </cmis:capabilityNewTypeSettableAttributes>
+      </cmis:capabilities>
+      <cmis:aclCapability>
+        <cmis:supportedPermissions>basic</cmis:supportedPermissions>
+        <cmis:propagation>objectonly</cmis:propagation>
+        <cmis:permissions>
+          <cmis:permission>cmis:read</cmis:permission>
+          <cmis:description>Read</cmis:description>
+        </cmis:permissions>
+        <cmis:permissions>
+          <cmis:permission>cmis:write</cmis:permission>
+          <cmis:description>Write</cmis:description>
+        </cmis:permissions>
+        <cmis:permissions>
+          <cmis:permission>cmis:all</cmis:permission>
+          <cmis:description>All</cmis:description>
+        </cmis:permissions>
+        <cmis:mapping>
+          <cmis:key>canCreateDocument.Folder</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canCreateFolder.Folder</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canDeleteContent.Document</cmis:key>
+          <cmis:permission>cmis:write</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canDelete.Object</cmis:key>
+          <cmis:permission>cmis:all</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canDeleteTree.Folder</cmis:key>
+          <cmis:permission>cmis:all</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canGetACL.Object</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canGetAllVersions.VersionSeries</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canGetChildren.Folder</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canGetDescendents.Folder</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canGetFolderParent.Object</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canGetParents.Folder</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canGetProperties.Object</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canMove.Object</cmis:key>
+          <cmis:permission>cmis:write</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canMove.Source</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canMove.Target</cmis:key>
+          <cmis:permission>cmis:write</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canSetContent.Document</cmis:key>
+          <cmis:permission>cmis:write</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canUpdateProperties.Object</cmis:key>
+          <cmis:permission>cmis:write</cmis:permission>
+        </cmis:mapping>
+        <cmis:mapping>
+          <cmis:key>canViewContent.Object</cmis:key>
+          <cmis:permission>cmis:read</cmis:permission>
+        </cmis:mapping>
+      </cmis:aclCapability>
+      <cmis:cmisVersionSupported>1.1</cmis:cmisVersionSupported>
+      <cmis:thinClientURI/>
+      <cmis:changesIncomplete>true</cmis:changesIncomplete>
+    </cmisra:repositoryInfo>
+    <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/typedescendants" href="http://example.com/cmisatom/test/typedesc" type="application/atom+xml;type=feed"/>
+    <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/foldertree" href="http://example.com/cmisatom/test/foldertree?id=%40root%40" type="application/cmistree+xml"/>
+    <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/rootdescendants" href="http://example.com/cmisatom/test/descendants?id=%40root%40" type="application/cmistree+xml" cmisra:id="@root@"/>
+    <cmisra:uritemplate>
+      <cmisra:template>http://example.com/cmisatom/test/id?id={id}&amp;filter={filter}&amp;includeAllowableActions={includeAllowableActions}&amp;includeACL={includeACL}&amp;includePolicyIds={includePolicyIds}&amp;includeRelationships={includeRelationships}&amp;renditionFilter={renditionFilter}</cmisra:template>
+      <cmisra:type>objectbyid</cmisra:type>
+      <cmisra:mediatype>application/atom+xml;type=entry</cmisra:mediatype>
+    </cmisra:uritemplate>
+    <cmisra:uritemplate>
+      <cmisra:template>http://example.com/cmisatom/test/path?path={path}&amp;filter={filter}&amp;includeAllowableActions={includeAllowableActions}&amp;includeACL={includeACL}&amp;includePolicyIds={includePolicyIds}&amp;includeRelationships={includeRelationships}&amp;renditionFilter={renditionFilter}</cmisra:template>
+      <cmisra:type>objectbypath</cmisra:type>
+      <cmisra:mediatype>application/atom+xml;type=entry</cmisra:mediatype>
+    </cmisra:uritemplate>
+    <cmisra:uritemplate>
+      <cmisra:template>http://example.com/cmisatom/test/type?id={id}</cmisra:template>
+      <cmisra:type>typebyid</cmisra:type>
+      <cmisra:mediatype>application/atom+xml;type=entry</cmisra:mediatype>
+    </cmisra:uritemplate>
+  </app:workspace>
+</app:service>
diff --git a/tests/data/cmis/cmis2.out.xml b/tests/data/cmis/cmis2.out.xml
new file mode 100644
index 00000000..52dc21a4
--- /dev/null
+++ b/tests/data/cmis/cmis2.out.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:app="http://www.w3.org/2007/app">
+  <atom:author>
+    <atom:name>cmisuser</atom:name>
+  </atom:author>
+  <atom:id>http://chemistry.apache.org/TDNSbGMzUXRaVzg9</atom:id>
+  <atom:published>2020-02-05T17:11:28Z</atom:published>
+  <atom:title>test-eo</atom:title>
+  <app:edited>2020-02-08T18:55:44Z</app:edited>
+  <atom:updated>2020-02-08T18:55:44Z</atom:updated>
+  <cmisra:object>
+    <cmis:properties>
+      <cmis:propertyId propertyDefinitionId="cmis:objectId">
+        <cmis:value>L3Rlc3QtZW8=</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyDateTime propertyDefinitionId="cmis:lastModificationDate">
+        <cmis:value>2020-02-08T18:55:44Z</cmis:value>
+      </cmis:propertyDateTime>
+      <cmis:propertyString propertyDefinitionId="cmis:changeToken"/>
+      <cmis:propertyString propertyDefinitionId="cmis:description"/>
+      <cmis:propertyId propertyDefinitionId="cmis:secondaryObjectTypeIds"/>
+      <cmis:propertyId propertyDefinitionId="cmis:baseTypeId">
+        <cmis:value>cmis:folder</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyString propertyDefinitionId="cmis:path">
+        <cmis:value>/test-eo</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyId propertyDefinitionId="cmis:parentId">
+        <cmis:value>@root@</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyId propertyDefinitionId="cmis:allowedChildObjectTypeIds"/>
+      <cmis:propertyString propertyDefinitionId="cmis:name">
+        <cmis:value>test-eo</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyId propertyDefinitionId="cmis:objectTypeId">
+        <cmis:value>cmis:folder</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyString propertyDefinitionId="cmis:createdBy">
+        <cmis:value>cmisuser</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyString propertyDefinitionId="cmis:lastModifiedBy">
+        <cmis:value>cmisuser</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyDateTime propertyDefinitionId="cmis:creationDate">
+        <cmis:value>2020-02-05T17:11:28Z</cmis:value>
+      </cmis:propertyDateTime>
+    </cmis:properties>
+  </cmisra:object>
+  <atom:link rel="service" href="http://example.com/cmisatom/test?repositoryId=test" type="application/atomsvc+xml"/>
+  <atom:link rel="self" href="http://example.com/cmisatom/test/entry?id=L3Rlc3QtZW8%3D" type="application/atom+xml;type=entry" cmisra:id="L3Rlc3QtZW8="/>
+  <atom:link rel="enclosure" href="http://example.com/cmisatom/test/entry?id=L3Rlc3QtZW8%3D" type="application/atom+xml;type=entry"/>
+  <atom:link rel="edit" href="http://example.com/cmisatom/test/entry?id=L3Rlc3QtZW8%3D" type="application/atom+xml;type=entry"/>
+  <atom:link rel="describedby" href="http://example.com/cmisatom/test/type?id=cmis%3Afolder" type="application/atom+xml;type=entry"/>
+  <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions" href="http://example.com/cmisatom/test/allowableactions?id=L3Rlc3QtZW8%3D" type="application/cmisallowableactions+xml"/>
+  <atom:link rel="up" href="http://example.com/cmisatom/test/parent?id=L3Rlc3QtZW8%3D" type="application/atom+xml;type=entry"/>
+  <atom:link rel="down" href="http://example.com/cmisatom/test/children?id=L3Rlc3QtZW8%3D" type="application/atom+xml;type=feed"/>
+  <atom:link rel="down" href="http://example.com/cmisatom/test/descendants?id=L3Rlc3QtZW8%3D" type="application/cmistree+xml"/>
+  <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/foldertree" href="http://example.com/cmisatom/test/foldertree?id=L3Rlc3QtZW8%3D" type="application/atom+xml;type=feed"/>
+  <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/acl" href="http://example.com/cmisatom/test/acl?id=L3Rlc3QtZW8%3D" type="application/cmisacl+xml"/>
+</atom:entry>
diff --git a/tests/data/cmis/cmis3.in.xml b/tests/data/cmis/cmis3.in.xml
new file mode 100644
index 00000000..634291b2
--- /dev/null
+++ b/tests/data/cmis/cmis3.in.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/">
+  <cmisra:content>
+    <cmisra:mediatype>application/binary</cmisra:mediatype>
+    <cmisra:base64>c2FsdXQK</cmisra:base64>
+  </cmisra:content>
+  <cmisra:object xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">
+    <cmis:properties>
+      <cmis:propertyString propertyDefinitionId="cmis:name">
+        <cmis:value>test2</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyId propertyDefinitionId="cmis:objectTypeId">
+        <cmis:value>cmis:document</cmis:value>
+      </cmis:propertyId>
+    </cmis:properties>
+  </cmisra:object>
+  <title>test2</title>
+</entry>
diff --git a/tests/data/cmis/cmis3.out.xml b/tests/data/cmis/cmis3.out.xml
new file mode 100644
index 00000000..dc9ec3dc
--- /dev/null
+++ b/tests/data/cmis/cmis3.out.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:app="http://www.w3.org/2007/app">
+  <atom:author>
+    <atom:name>cmisuser</atom:name>
+  </atom:author>
+  <atom:id>http://chemistry.apache.org/TDNSbGMzUXRaVzh2ZEdWemREST0=</atom:id>
+  <atom:published>2020-02-08T19:17:10Z</atom:published>
+  <atom:title>test2</atom:title>
+  <app:edited>2020-02-08T19:17:10Z</app:edited>
+  <atom:updated>2020-02-08T19:17:10Z</atom:updated>
+  <atom:content src="http://example.com/cmisatom/test/content/test2?id=L3Rlc3QtZW8vdGVzdDI%3D" type="application/octet-stream"/>
+  <cmisra:object>
+    <cmis:properties>
+      <cmis:propertyId propertyDefinitionId="cmis:objectId">
+        <cmis:value>L3Rlc3QtZW8vdGVzdDI=</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyDateTime propertyDefinitionId="cmis:lastModificationDate">
+        <cmis:value>2020-02-08T19:17:10Z</cmis:value>
+      </cmis:propertyDateTime>
+      <cmis:propertyString propertyDefinitionId="cmis:changeToken"/>
+      <cmis:propertyString propertyDefinitionId="cmis:description"/>
+      <cmis:propertyId propertyDefinitionId="cmis:secondaryObjectTypeIds"/>
+      <cmis:propertyId propertyDefinitionId="cmis:baseTypeId">
+        <cmis:value>cmis:document</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyBoolean propertyDefinitionId="cmis:isImmutable">
+        <cmis:value>false</cmis:value>
+      </cmis:propertyBoolean>
+      <cmis:propertyBoolean propertyDefinitionId="cmis:isLatestVersion">
+        <cmis:value>true</cmis:value>
+      </cmis:propertyBoolean>
+      <cmis:propertyBoolean propertyDefinitionId="cmis:isMajorVersion">
+        <cmis:value>true</cmis:value>
+      </cmis:propertyBoolean>
+      <cmis:propertyBoolean propertyDefinitionId="cmis:isLatestMajorVersion">
+        <cmis:value>true</cmis:value>
+      </cmis:propertyBoolean>
+      <cmis:propertyString propertyDefinitionId="cmis:versionLabel">
+        <cmis:value>test2</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyId propertyDefinitionId="cmis:versionSeriesId">
+        <cmis:value>L3Rlc3QtZW8vdGVzdDI=</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyBoolean propertyDefinitionId="cmis:isVersionSeriesCheckedOut">
+        <cmis:value>false</cmis:value>
+      </cmis:propertyBoolean>
+      <cmis:propertyString propertyDefinitionId="cmis:versionSeriesCheckedOutBy"/>
+      <cmis:propertyString propertyDefinitionId="cmis:versionSeriesCheckedOutId"/>
+      <cmis:propertyString propertyDefinitionId="cmis:checkinComment">
+        <cmis:value/>
+      </cmis:propertyString>
+      <cmis:propertyBoolean propertyDefinitionId="cmis:isPrivateWorkingCopy">
+        <cmis:value>false</cmis:value>
+      </cmis:propertyBoolean>
+      <cmis:propertyInteger propertyDefinitionId="cmis:contentStreamLength">
+        <cmis:value>6</cmis:value>
+      </cmis:propertyInteger>
+      <cmis:propertyString propertyDefinitionId="cmis:contentStreamMimeType">
+        <cmis:value>application/octet-stream</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyString propertyDefinitionId="cmis:contentStreamFileName">
+        <cmis:value>test2</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyId propertyDefinitionId="cmis:contentStreamId"/>
+      <cmis:propertyString propertyDefinitionId="cmis:name">
+        <cmis:value>test2</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyId propertyDefinitionId="cmis:objectTypeId">
+        <cmis:value>cmis:document</cmis:value>
+      </cmis:propertyId>
+      <cmis:propertyString propertyDefinitionId="cmis:createdBy">
+        <cmis:value>cmisuser</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyString propertyDefinitionId="cmis:lastModifiedBy">
+        <cmis:value>cmisuser</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyDateTime propertyDefinitionId="cmis:creationDate">
+        <cmis:value>2020-02-08T19:17:10Z</cmis:value>
+      </cmis:propertyDateTime>
+    </cmis:properties>
+  </cmisra:object>
+  <atom:link rel="service" href="http://example.com/cmisatom/test?repositoryId=test" type="application/atomsvc+xml"/>
+  <atom:link rel="self" href="http://example.com/cmisatom/test/entry?id=L3Rlc3QtZW8vdGVzdDI%3D" type="application/atom+xml;type=entry" cmisra:id="L3Rlc3QtZW8vdGVzdDI="/>
+  <atom:link rel="enclosure" href="http://example.com/cmisatom/test/entry?id=L3Rlc3QtZW8vdGVzdDI%3D" type="application/atom+xml;type=entry"/>
+  <atom:link rel="edit" href="http://example.com/cmisatom/test/entry?id=L3Rlc3QtZW8vdGVzdDI%3D" type="application/atom+xml;type=entry"/>
+  <atom:link rel="describedby" href="http://example.com/cmisatom/test/type?id=cmis%3Adocument" type="application/atom+xml;type=entry"/>
+  <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/allowableactions" href="http://example.com/cmisatom/test/allowableactions?id=L3Rlc3QtZW8vdGVzdDI%3D" type="application/cmisallowableactions+xml"/>
+  <atom:link rel="up" href="http://example.com/cmisatom/test/parents?id=L3Rlc3QtZW8vdGVzdDI%3D" type="application/atom+xml;type=feed"/>
+  <atom:link rel="edit-media" href="http://example.com/cmisatom/test/content?id=L3Rlc3QtZW8vdGVzdDI%3D" type="application/octet-stream"/>
+  <atom:link rel="http://docs.oasis-open.org/ns/cmis/link/200908/acl" href="http://example.com/cmisatom/test/acl?id=L3Rlc3QtZW8vdGVzdDI%3D" type="application/cmisacl+xml"/>
+</atom:entry>
diff --git a/tests/test_cmis.py b/tests/test_cmis.py
index 07817721..22af5eb6 100644
--- a/tests/test_cmis.py
+++ b/tests/test_cmis.py
@@ -1,5 +1,8 @@
 import base64
 import httplib2
+from lxml import etree
+import mock
+import os
 import re
 
 from cmislib import CmisClient
@@ -8,6 +11,8 @@ from cmislib.exceptions import ObjectNotFoundException
 from cmislib.exceptions import PermissionDeniedException
 from cmislib.exceptions import UpdateConflictException
 from django.contrib.contenttypes.models import ContentType
+from django.core.urlresolvers import reverse
+from django.utils import six
 from django.utils.encoding import force_bytes, force_text
 from django.utils.six.moves.urllib import error as urllib2
 from mock import call, Mock
@@ -351,3 +356,46 @@ def test_re_file_name():
     RE_FILE_NAME = re.compile(FILE_NAME_PATTERN)
     assert RE_FILE_NAME.match('toto.tata')
     assert RE_FILE_NAME.match('TOTO.TATA')
+
+
+@mock.patch('httplib2.Http.request')
+def test_raw_uploadfile(mocked_request, app, setup):
+    """ Simulate the bellow bash query :
+    $ http https://passerelle.dev.publik.love/cmis/ged/uploadfile \
+           file:='{"filename": "test2", "content": "c2FsdXQK"}' path=/test-eo
+    """
+    file_name = "test2"
+    file_content = 'salut\n'
+    path = "/test-eo"
+    url = reverse('generic-endpoint', kwargs={'connector': 'cmis',
+                  'endpoint': 'uploadfile', 'slug': setup.slug})
+
+    def cmis_mocked_request(uri, method="GET", body=None, **kwargs):
+        """simulate the 3 (ordered) HTTP queries involved"""
+        response = {'status': '200'}
+        if method == 'GET' and uri == 'http://example.com/cmisatom':
+            content = open('%s/tests/data/cmis/cmis1.out.xml' % os.getcwd(), 'rb').read()
+        elif method == 'GET' and uri == 'http://example.com/cmisatom/test/path?path=/test-eo&filter=&includeAllowableActions=false&includeACL=false&includePolicyIds=false&includeRelationships=&renditionFilter=':
+            content = open('%s/tests/data/cmis/cmis2.out.xml' % os.getcwd(), 'rb').read()
+        elif method == 'POST' and uri == 'http://example.com/cmisatom/test/children?id=L3Rlc3QtZW8%3D':
+            if six.PY3:
+                expected_input = open('%s/tests/data/cmis/cmis3.in.xml' % os.getcwd(), 'rb').read()
+                input1 = etree.tostring(etree.fromstring(expected_input), pretty_print=True)
+                input2 = etree.tostring(etree.fromstring(body), pretty_print=True)
+                assert input1 == input2
+            content = open('%s/tests/data/cmis/cmis3.out.xml' % os.getcwd(), 'rb').read()
+        else:
+            raise Exception('my fault error, url is not yet mocked: %s' % uri)
+        return (response, content)
+
+    mocked_request.side_effect = cmis_mocked_request
+    params = {
+        "path": path,
+        "file": {"filename": file_name,
+                 "content": b64encode(file_content),
+                 "content_type": "image/jpeg"}}
+    response = app.post_json(url, params=params)
+    json_result = response.json
+    assert json_result['err'] == 0
+    assert json_result['data']['properties']['cmis:objectTypeId'] == "cmis:document"
+    assert json_result['data']['properties']['cmis:name'] == file_name
-- 
2.24.1

