Remove Robohydra (obsoleted by okhttp-mockwebserver)

pull/2/head
Ricki Hirner 9 years ago
parent da9410c1b5
commit 3646a561c6
No known key found for this signature in database
GPG Key ID: C4A212CF0B2B4566

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2013 2015 Ricki Hirner (bitfire web engineering).
~ All rights reserved. This program and the accompanying materials
~ are made available under the terms of the GNU Public License v3.0
~ which accompanies this distribution, and is available at
~ http://www.gnu.org/licenses/gpl.html
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
style="@style/TextView.Heading"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/setup_task_lists" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="@string/setup_select_task_lists" />
</LinearLayout>

@ -1,5 +0,0 @@
{"plugins":[
"assets",
"redirect",
"dav"
]}

@ -1,12 +0,0 @@
var RoboHydraHeadFilesystem = require("robohydra").heads.RoboHydraHeadFilesystem;
exports.getBodyParts = function(conf) {
return {
heads: [
new RoboHydraHeadFilesystem({
mountPath: '/assets/',
documentRoot: '../assets'
})
]
};
};

@ -1,386 +0,0 @@
// vim: ts=4:sw=4
var roboHydraHeadDAV = require("../headdav");
exports.getBodyParts = function(conf) {
return {
heads: [
/* base URL, provide default DAV here */
new RoboHydraHeadDAV({ path: "/dav/" }),
/* test cookie:
* POST /dav/testCookieStore will cause the mock server to set a cookie
* GET /dav/testCookieStore will cause the mock server to check the request cookie
* and return 412 Precondition failed when it's not set correctly
*/
new RoboHydraHeadDAV({
path: "/dav/testCookieStore",
handler: function(req,res,next) {
var cookie = 'sess=MY_SESSION_12345';
if (req.method == "POST") {
res.statusCode = 200;
res.headers['Set-Cookie'] = cookie;
res.send("Setting cookie");
} else {
res.statusCode = (req.headers['cookie'] == cookie) ? 200 : 412;
res.send("Checking cookie");
}
}
}),
/* multistatus parsing */
new RoboHydraHeadDAV({
path: "/dav/collection-response-with-trailing-slash",
handler: function(req,res,next) {
if (req.method == "PROPFIND") {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:">\
<response>\
<href>/dav/collection-response-with-trailing-slash/</href> \
<propstat>\
<prop>\
<current-user-principal>\
<href>/principals/ok</href>\
</current-user-principal>\
<resourcetype>\
<collection/>\
</resourcetype>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
</multistatus>\
');
}
}
}),
new RoboHydraHeadDAV({
path: "/dav/collection-response-without-trailing-slash",
handler: function(req,res,next) {
if (req.method == "PROPFIND") {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:">\
<response>\
<href>/dav/collection-response-without-trailing-slash</href> \
<propstat>\
<prop>\
<current-user-principal>\
<href>/principals/ok</href>\
</current-user-principal>\
<resourcetype>\
<collection/>\
</resourcetype>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
</multistatus>\
');
}
}
}),
new RoboHydraHeadDAV({
path: "/dav/propfind-collection-properties",
handler: function(req,res,next) {
if (req.method == "PROPFIND") {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">\
<response>\
<href>/dav/propfind-collection-properties</href> \
<propstat>\
<prop>\
<resourcetype>\
<collection/>\
<CARD:addressbook/>\
</resourcetype>\
<CARD:supported-address-data>\
<address-data-type content-type="text/vcard" version="4.0"/>\
</CARD:supported-address-data>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
<propstat>\
<prop>\
<displayname/>\
<A:calendar-color xmlns:A="http://apple.com/ns/ical/">0xFF00FF</A:calendar-color>\
</prop>\
<status>HTTP/1.1 404 Not Found</status>\
</propstat>\
</response>\
</multistatus>\
');
}
}
}),
/* principal URL */
new RoboHydraHeadDAV({
path: "/dav/principals/users/test",
handler: function(req,res,next) {
if (req.method == "PROPFIND" && req.rawBody.toString().match(/home-?set/)) {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:">\
<response>\
<href>/dav/principals/users/t%65st</href> \
<propstat>\
<prop>\
<CARD:addressbook-home-set xmlns:CARD="urn:ietf:params:xml:ns:carddav">\
<href>/dav/addressbooks/test</href>\
</CARD:addressbook-home-set>\
<CAL:calendar-home-set xmlns:CAL="urn:ietf:params:xml:ns:caldav">\
<href>/dav/calendars/test/</href>\
</CAL:calendar-home-set>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
</multistatus>\
');
}
}
}),
/* address-book home set */
new RoboHydraHeadDAV({
path: "/dav/addressbooks/test/",
handler: function(req,res,next) {
if (!req.url.match(/\/$/)) {
res.statusCode = 302;
res.headers['location'] = "/dav/addressbooks/test/";
}
else if (req.method == "PROPFIND" && req.rawBody.toString().match(/addressbook-description/)) {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:">\
<response>\
<href>/dav/addressbooks/test/useless-member</href>\
<propstat>\
<prop>\
<resourcetype/>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
<response>\
<href>/dav/addressbooks/test/default.vcf</href>\
<propstat>\
<prop xmlns:CARD="urn:ietf:params:xml:ns:carddav">\
<resourcetype>\
<collection/>\
<CARD:addressbook/>\
</resourcetype>\
<CARD:addressbook-description>Default Address Book</CARD:addressbook-description>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
<response>\
<href>https://my.server/absolute:uri/my-address-book</href>\
<propstat>\
<prop xmlns:CARD="urn:ietf:params:xml:ns:carddav">\
<resourcetype>\
<collection/>\
<CARD:addressbook/>\
</resourcetype>\
<CARD:addressbook-description>Absolute URI VCard Book</CARD:addressbook-description>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
</multistatus>\
');
}
}
}),
/* calendar home set */
new RoboHydraHeadDAV({
path: "/dav/calendars/test/",
handler: function(req,res,next) {
if (req.method == "PROPFIND" && req.rawBody.toString().match(/calendar-description/)) {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav">\
<response>\
<href>/dav/calendars/test/shared.forbidden</href>\
<propstat>\
<prop>\
<resourcetype/>\
</prop>\
<status>HTTP/1.1 403 Forbidden</status>\
</propstat>\
</response>\
<response>\
<href>/dav/calendars/test/private.ics</href>\
<propstat>\
<prop>\
<resourcetype>\
<collection/>\
<CAL:calendar/>\
</resourcetype>\
<displayname>Private Calendar</displayname>\
<CAL:calendar-description>This is my private calendar.</CAL:calendar-description>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
<response>\
<href>/dav/calendars/test/work.ics</href>\
<propstat>\
<prop>\
<resourcetype>\
<collection/>\
<CAL:calendar/>\
</resourcetype>\
<current-user-privilege-set>\
<privilege><read/></privilege>\
</current-user-privilege-set>\
<displayname>Work Calendar</displayname>\
<A:calendar-color xmlns:A="http://apple.com/ns/ical/">0xFF00FF</A:calendar-color>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
</multistatus>\
');
}
}
}),
/* non-existing member */
new RoboHydraHeadDAV({
path: "/dav/collection/new.file",
handler: function(req,res,next) {
if (req.method == "PUT") {
if (req.headers['if-match']) /* can't overwrite new file */
res.statusCode = 412;
else {
res.statusCode = 201;
res.headers["ETag"] = "has-just-been-created";
}
} else if (req.method == "DELETE")
res.statusCode = 404;
}
}),
/* existing member */
new RoboHydraHeadDAV({
path: "/dav/collection/existing.file",
handler: function(req,res,next) {
if (req.method == "PUT") {
if (req.headers['if-none-match']) /* requested "don't overwrite", but this file exists */
res.statusCode = 412;
else if (req.headers['if-match'] && req.queryParams && req.queryParams.conflict)
/* requested "don't overwrite", but this file exists with newer content */
res.statusCode = 409;
else {
res.statusCode = 204;
res.headers["ETag"] = "has-just-been-updated";
}
} else if (req.method == "DELETE")
res.statusCode = 204;
}
}),
/* existing member with encoded URL as file name */
new RoboHydraHeadDAV({
path: "/dav/http%253A%252F%252Fwww.invalid.example%252Fm8%252Ffeeds%252Fcontacts%252Fmaria.mueller%252540gmail.com%252Fbase%252F5528abc5720cecc.vcf",
handler: function(req,res,next) {
if (req.method == "GET")
res.statusCode = 200;
}
}),
/* address-book multiget */
new RoboHydraHeadDAV({
path: "/dav/addressbooks/default.vcf/",
handler: function(req,res,next) {
if (req.method == "REPORT" && req.rawBody.toString().match(/addressbook-multiget[\s\S]+<prop>[\s\S]+<href>/m &&
req.rawBody.toString().match(/<href>\/dav\/addressbooks\/default\.vcf\/2:3@my%2540pc\.vcf<\/href>/m))) {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">\
<response>\
<href>/dav/addressbooks/default.vcf</href>\
<propstat>\
<prop>\
<resourcetype><collection/></resourcetype>\
<displayname>My Book</displayname>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
<response>\
<href>/dav/addressbooks/default.vcf/1.vcf</href>\
<propstat>\
<prop>\
<getetag/>\
<CARD:address-data>BEGIN:VCARD\
VERSION:3.0\
NICKNAME:MULTIGET1\
UID:1\
END:VCARD\
</CARD:address-data>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
<response>\
<href>/dav/addressbooks/default.vcf/2:3%40my%2540pc.vcf</href>\
<propstat>\
<prop>\
<getetag/>\
<CARD:address-data>BEGIN:VCARD\
VERSION:3.0\
NICKNAME:MULTIGET2\
UID:2\
END:VCARD\
</CARD:address-data>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
</multistatus>\
');
}
}
}),
/* address-book multiget where one resource has 404 Not Found */
new RoboHydraHeadDAV({
path: "/dav/addressbooks/default-with-404.vcf/",
handler: function(req,res,next) {
if (req.method == "REPORT" && req.rawBody.toString().match(/addressbook-multiget[\s\S]+<prop>[\s\S]+<href>/m &&
req.rawBody.toString().match(/<href>\/dav\/addressbooks\/default-with-404\.vcf\/notexisting<\/href>/m))) {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:" xmlns:CARD="urn:ietf:params:xml:ns:carddav">\
<response>\
<href>/dav/addressbooks/default-with-404.vcf</href>\
<propstat>\
<prop>\
<resourcetype><collection/></resourcetype>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
<response>\
<href>/dav/addressbooks/default-with-404.vcf/notexisting</href>\
<status>HTTP/1.1 404 Not Found</status>\
</response>\
</multistatus>\
');
}
}
}),
]
};
};

@ -1,59 +0,0 @@
// vim: ts=4:sw=4
var roboHydra = require("robohydra"),
roboHydraHeads = roboHydra.heads,
roboHydraHead = roboHydraHeads.RoboHydraHead;
RoboHydraHeadDAV = roboHydraHeads.robohydraHeadType({
name: 'WebDAV Server',
mandatoryProperties: [ 'path' ],
optionalProperties: [ 'handler' ],
parentPropertyBuilder: function() {
var myHandler = this.handler;
return {
path: this.path,
handler: function(req,res,next) {
// default DAV behavior
res.headers['DAV'] = 'addressbook, calendar-access';
res.statusCode = 500;
// verify Accept header
var accept = req.headers['accept'];
if (req.method == "GET" && (accept == undefined || !accept.match(/text\/(calendar|vcard|xml)/)) ||
(req.method == "PROPFIND" || req.method == "REPORT") && (accept == undefined || accept != "text/xml"))
res.statusCode = 406;
// DAV operations that work on all URLs
else if (req.method == "OPTIONS") {
res.statusCode = 204;
res.headers['Allow'] = 'OPTIONS, PROPFIND, GET, PUT, DELETE, REPORT';
} else if (req.method == "PROPFIND" && req.rawBody.toString().match(/current-user-principal/)) {
res.statusCode = 207;
res.write('\<?xml version="1.0" encoding="utf-8" ?>\
<multistatus xmlns="DAV:">\
<response>\
<href>' + req.url + '</href> \
<propstat>\
<prop>\
<current-user-principal>\
<href>/dav/principals/users/test</href>\
</current-user-principal>\
</prop>\
<status>HTTP/1.1 200 OK</status>\
</propstat>\
</response>\
</multistatus>\
');
} else if (typeof myHandler != 'undefined')
myHandler(req,res,next);
res.end();
}
}
}
});
module.exports = RoboHydraHeadDAV;

@ -1,57 +0,0 @@
require('../simple');
var RoboHydraHead = require('robohydra').heads.RoboHydraHead;
exports.getBodyParts = function(conf) {
return {
heads: [
// well-known URIs
new SimpleResponseHead({
path: '/.well-known/caldav',
status: 302,
headers: { Location: '/dav/' }
}),
new SimpleResponseHead({
path: '/.well-known/carddav',
status: 302,
headers: { Location: '/dav/' }
}),
// generic redirections
new RoboHydraHead({
path: '/redirect/301',
handler: function(req,res,next) {
res.statusCode = 301;
var location = req.queryParams['to'] || '/assets/test.random';
res.headers = {
Location: location
}
res.end();
}
}),
new RoboHydraHead({
path: '/redirect/302',
handler: function(req,res,next) {
res.statusCode = 302;
var location = req.queryParams['to'] || '/assets/test.random';
res.headers = {
Location: location
}
res.end();
}
}),
// special redirections
new SimpleResponseHead({
path: '/redirect/relative',
status: 302,
headers: { Location: '/new/location' }
}),
new SimpleResponseHead({
path: '/redirect/without-location',
status: 302
})
]
};
};

@ -1,30 +0,0 @@
// vim: ts=4:sw=4
var roboHydra = require("robohydra"),
roboHydraHeads = roboHydra.heads,
roboHydraHead = roboHydraHeads.RoboHydraHead;
SimpleResponseHead = roboHydraHeads.robohydraHeadType({
name: 'Simple HTTP Response',
mandatoryProperties: [ 'path', 'status' ],
optionalProperties: [ 'headers', 'body' ],
parentPropertyBuilder: function() {
var head = this;
return {
path: this.path,
handler: function(req,res,next) {
res.statusCode = head.status;
if (typeof head.headers != 'undefined')
res.headers = head.headers;
if (typeof head.body != 'undefined')
res.write(head.body);
else
res.write();
res.end();
}
}
}
});
module.exports = SimpleResponseHead;

@ -1,2 +0,0 @@
#!/bin/sh
node_modules/robohydra/bin/robohydra.js davdroid.conf -I plugins

@ -272,8 +272,6 @@ public class DavResourceFinder {
log.debug("PROPFIND on " + url + " failed", e);
}
// TODO notify user on errors?
if (service == Service.CALDAV) {
serverInfo.setCalendars(calendars.values().toArray(new ServerInfo.ResourceInfo[calendars.size()]));
serverInfo.setTaskLists(taskLists.values().toArray(new ServerInfo.ResourceInfo[taskLists.size()]));

Loading…
Cancel
Save