aboutsummaryrefslogtreecommitdiffstats
path: root/test.js
blob: cb20ad2d4a1c31e5581d3d014bd2a48576572176 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var XHR = require('./lib/webcals/xhr.js');
var url, user, pass, domain;

function getBody(file) {
  return require('fs').readFileSync(
    __dirname + '/samples/' + file, 'utf8'
  );
}

domain = 'http://lowebcals.com';
uri = '/calendars/admin';
user = 'admin';
pass = 'admin';

function request(options) {
  var defaults = {
    user: user,
    password: pass,
    url: domain + uri + (options.uri || ''),
    headers: {
      Depth: 0
    }
  };

  if (typeof(options) === 'undefined') {
    options = {};
  }

  for (var key in options) {
    if (options.hasOwnProperty(key)) {
      defaults[key] = options[key];
    }
  }

  return new XHR(defaults);
}



function getProps() {

 var  body = '<?xml version="1.0" encoding="utf-8" ?>' +
  '<D:propfind xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:webcals">' +
   '<D:prop>' +
     '<C:calendar-home-set/>' +
     '<C:calendar-user-address-set/>' +
     '<C:schedule-inbox-URL/>' +
     '<C:schedule-outbox-URL/>' +
   '</D:prop>' +
  '</D:propfind>';


  var xhr = request({
    method: 'PROPFIND',
    data: body,
    headers: {
      'Depth': 0
    }
  });

  xhr.send(function(text, xhr) {
    console.log(xhr.responseText);
  });
}


function getCalenders() {
  var body = getBody('calendar-data');

  var xhr = request({
    url: domain + '/calendar/dav/james%40lightsofapollo.com/',
    method: 'REPORT',
    headers: {
      Depth: 1
    },
    data: body
  });

  xhr.send(function(text) {
    console.log(text);
  });
}


function checkResource() {
  var body = getBody('resource-type'),
      xhr;

  xhr = request({
    uri: '/default',
    method: 'PROPFIND',
    data: body
  });

  xhr.send(function(text) {
    console.log(text);
  });

}

checkResource();

//getCalenders();
//getProps();