reedb 0.10.rc1 → 0.11

Sign up to get free protection for your applications and to get access to all the features.
data/reedb.gemspec CHANGED
@@ -4,28 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require_relative 'lib/reedb/constants'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "reedb"
8
- spec.version = Reedb::VERSION
9
- spec.authors = ["Lonely Robot", "Katharina Sabel"]
10
- spec.email = ["sabel.katharina@gmail.com"]
11
- spec.summary = %q{Ruby storage containers/ database that uses completely encrpypted files for maximum security.}
12
- spec.description = %q{Ruby storage containers/ database. Uses Rinjdael, Twofish, ... to keep your data safe. Made for native and local application development. Spawns a system daemon that manages vaults that applications can talk to.}
13
- spec.homepage = "https://github.com/tr-lonelyrobot/reedb/wiki"
14
- spec.license = "LGPL v3.0"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
-
24
- spec.add_dependency 'aes', '~> 0.5'
25
- spec.add_dependency 'twofish', '~> 1.0'
26
- spec.add_dependency 'digest-tiger', '~> 1.0'
27
- spec.add_dependency 'json', '~> 1.8'
28
- spec.add_dependency 'daemons', '~> 1.2'
29
- spec.add_dependency 'sinatra', '~> 1.4'
30
- spec.add_dependency 'hashids', '~> 1.0'
7
+ spec.name = 'reedb'
8
+ spec.version = Reedb::VERSION
9
+
10
+ spec.authors = ['Katharina Sabel']
11
+ spec.email = ['sabel.katharina@gmail.com']
12
+
13
+ spec.summary = %q{Ruby database that uses completely encrypted files for maximum security}
14
+
15
+ spec.description = %q{Ruby storage containers/ database. Uses Rinjdael, Twofish, ... to keep your data safe. Made for native and local application development. Spawns a system daemon that manages vaults that applications can talk to or provides a powerful interface to interact with vaults from within other ruby applications. Check the wiki for details}
16
+
17
+ spec.homepage = 'https://github.com/tr-lonelyrobot/reedb/'
18
+ spec.license = 'LGPL v3.0'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0")
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = %w{ lib bin }
24
+
25
+ # Define required ruby version
26
+ spec.required_ruby_version = '~> 2.1'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.7'
29
+ spec.add_development_dependency 'yard', '~> 0.8'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+
32
+ spec.add_dependency 'aes', '~> 0.5'
33
+ spec.add_dependency 'twofish', '~> 1.0'
34
+ spec.add_dependency 'digest-tiger', '~> 1.0'
35
+ spec.add_dependency 'json', '~> 1.8'
36
+ spec.add_dependency 'daemons', '~> 1.2'
37
+ spec.add_dependency 'sinatra', '~> 1.4'
38
+ spec.add_dependency 'uuid', '~> 2.3'
31
39
  end
@@ -0,0 +1,238 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ Q1 = $(V:1=)
7
+ Q = $(Q1:0=@)
8
+ ECHO1 = $(V:1=@:)
9
+ ECHO = $(ECHO1:0=@echo)
10
+
11
+ #### Start of system configuration section. ####
12
+
13
+ srcdir = .
14
+ topdir = /home/spacekookie/.rvm/rubies/ruby-2.1.6/include/ruby-2.1.0
15
+ hdrdir = $(topdir)
16
+ arch_hdrdir = /home/spacekookie/.rvm/rubies/ruby-2.1.6/include/ruby-2.1.0/x86_64-linux
17
+ PATH_SEPARATOR = :
18
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
+ prefix = $(DESTDIR)/home/spacekookie/.rvm/rubies/ruby-2.1.6
20
+ rubysitearchprefix = $(rubylibprefix)/$(sitearch)
21
+ rubyarchprefix = $(rubylibprefix)/$(arch)
22
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
23
+ exec_prefix = $(prefix)
24
+ vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
25
+ sitearchhdrdir = $(sitehdrdir)/$(sitearch)
26
+ rubyarchhdrdir = $(rubyhdrdir)/$(arch)
27
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
28
+ sitehdrdir = $(rubyhdrdir)/site_ruby
29
+ rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
30
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
31
+ vendorlibdir = $(vendordir)/$(ruby_version)
32
+ vendordir = $(rubylibprefix)/vendor_ruby
33
+ sitearchdir = $(sitelibdir)/$(sitearch)
34
+ sitelibdir = $(sitedir)/$(ruby_version)
35
+ sitedir = $(rubylibprefix)/site_ruby
36
+ rubyarchdir = $(rubylibdir)/$(arch)
37
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
38
+ sitearchincludedir = $(includedir)/$(sitearch)
39
+ archincludedir = $(includedir)/$(arch)
40
+ sitearchlibdir = $(libdir)/$(sitearch)
41
+ archlibdir = $(libdir)/$(arch)
42
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
43
+ mandir = $(datarootdir)/man
44
+ localedir = $(datarootdir)/locale
45
+ libdir = $(exec_prefix)/lib
46
+ psdir = $(docdir)
47
+ pdfdir = $(docdir)
48
+ dvidir = $(docdir)
49
+ htmldir = $(docdir)
50
+ infodir = $(datarootdir)/info
51
+ docdir = $(datarootdir)/doc/$(PACKAGE)
52
+ oldincludedir = $(DESTDIR)/usr/include
53
+ includedir = $(prefix)/include
54
+ localstatedir = $(prefix)/var
55
+ sharedstatedir = $(prefix)/com
56
+ sysconfdir = $(prefix)/etc
57
+ datadir = $(datarootdir)
58
+ datarootdir = $(prefix)/share
59
+ libexecdir = $(exec_prefix)/libexec
60
+ sbindir = $(exec_prefix)/sbin
61
+ bindir = $(exec_prefix)/bin
62
+ archdir = $(rubyarchdir)
63
+
64
+
65
+ CC = gcc
66
+ CXX = g++
67
+ LIBRUBY = $(LIBRUBY_SO)
68
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
69
+ LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
70
+ LIBRUBYARG_STATIC = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
71
+ empty =
72
+ OUTFLAG = -o $(empty)
73
+ COUTFLAG = -o $(empty)
74
+
75
+ RUBY_EXTCONF_H =
76
+ cflags = $(optflags) $(debugflags) $(warnflags)
77
+ optflags = -O3 -fno-fast-math
78
+ debugflags = -ggdb3
79
+ warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
80
+ CCDLFLAGS = -fPIC
81
+ CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
82
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
83
+ DEFS =
84
+ CPPFLAGS = $(DEFS) $(cppflags)
85
+ CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
86
+ ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
87
+ dldflags =
88
+ ARCH_FLAG =
89
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
90
+ LDSHARED = $(CC) -shared
91
+ LDSHAREDXX = $(CXX) -shared
92
+ AR = ar
93
+ EXEEXT =
94
+
95
+ RUBY_INSTALL_NAME = ruby
96
+ RUBY_SO_NAME = ruby
97
+ RUBYW_INSTALL_NAME =
98
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
99
+ RUBYW_BASE_NAME = rubyw
100
+ RUBY_BASE_NAME = ruby
101
+
102
+ arch = x86_64-linux
103
+ sitearch = $(arch)
104
+ ruby_version = 2.1.0
105
+ ruby = $(bindir)/ruby
106
+ RUBY = $(ruby)
107
+ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
108
+
109
+ RM = rm -f
110
+ RM_RF = $(RUBY) -run -e rm -- -rf
111
+ RMDIRS = rmdir --ignore-fail-on-non-empty -p
112
+ MAKEDIRS = /bin/mkdir -p
113
+ INSTALL = /bin/install -c
114
+ INSTALL_PROG = $(INSTALL) -m 0755
115
+ INSTALL_DATA = $(INSTALL) -m 644
116
+ COPY = cp
117
+ TOUCH = exit >
118
+
119
+ #### End of system configuration section. ####
120
+
121
+ preload =
122
+
123
+ libpath = . $(libdir)
124
+ LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir)
125
+ DEFFILE =
126
+
127
+ CLEANFILES = mkmf.log
128
+ DISTCLEANFILES =
129
+ DISTCLEANDIRS =
130
+
131
+ extout =
132
+ extout_prefix =
133
+ target_prefix =
134
+ LOCAL_LIBS =
135
+ LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lcrypt -lm -lc
136
+ ORIG_SRCS = MyTest.c
137
+ SRCS = $(ORIG_SRCS)
138
+ OBJS = MyTest.o
139
+ HDRS =
140
+ TARGET = mytest
141
+ TARGET_NAME = mytest
142
+ TARGET_ENTRY = Init_$(TARGET_NAME)
143
+ DLLIB = $(TARGET).so
144
+ EXTSTATIC =
145
+ STATIC_LIB =
146
+
147
+ TIMESTAMP_DIR = .
148
+ BINDIR = $(bindir)
149
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
150
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
151
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
152
+ HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
153
+ ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
154
+
155
+ TARGET_SO = $(DLLIB)
156
+ CLEANLIBS = $(TARGET).so
157
+ CLEANOBJS = *.o *.bak
158
+
159
+ all: $(DLLIB)
160
+ static: $(STATIC_LIB)
161
+ .PHONY: all install static install-so install-rb
162
+ .PHONY: clean clean-so clean-static clean-rb
163
+
164
+ clean-static::
165
+ clean-rb-default::
166
+ clean-rb::
167
+ clean-so::
168
+ clean: clean-so clean-static clean-rb-default clean-rb
169
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
170
+
171
+ distclean-rb-default::
172
+ distclean-rb::
173
+ distclean-so::
174
+ distclean-static::
175
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
176
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
177
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
178
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
179
+
180
+ realclean: distclean
181
+ install: install-so install-rb
182
+
183
+ install-so: $(DLLIB) $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
184
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
185
+ clean-static::
186
+ -$(Q)$(RM) $(STATIC_LIB)
187
+ install-rb: pre-install-rb install-rb-default
188
+ install-rb-default: pre-install-rb-default
189
+ pre-install-rb: Makefile
190
+ pre-install-rb-default: Makefile
191
+ pre-install-rb-default:
192
+ $(ECHO) installing default mytest libraries
193
+ $(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
194
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
195
+ $(Q) $(TOUCH) $@
196
+
197
+ site-install: site-install-so site-install-rb
198
+ site-install-so: install-so
199
+ site-install-rb: install-rb
200
+
201
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
202
+
203
+ .cc.o:
204
+ $(ECHO) compiling $(<)
205
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
206
+
207
+ .mm.o:
208
+ $(ECHO) compiling $(<)
209
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
210
+
211
+ .cxx.o:
212
+ $(ECHO) compiling $(<)
213
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
214
+
215
+ .cpp.o:
216
+ $(ECHO) compiling $(<)
217
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
218
+
219
+ .C.o:
220
+ $(ECHO) compiling $(<)
221
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
222
+
223
+ .c.o:
224
+ $(ECHO) compiling $(<)
225
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
226
+
227
+ .m.o:
228
+ $(ECHO) compiling $(<)
229
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
230
+
231
+ $(DLLIB): $(OBJS) Makefile
232
+ $(ECHO) linking shared-object $(DLLIB)
233
+ -$(Q)$(RM) $(@)
234
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
235
+
236
+
237
+
238
+ $(OBJS): $(HDRS) $(ruby_headers)
@@ -0,0 +1,27 @@
1
+ // Include the Ruby headers and goodies
2
+ #include "ruby.h"
3
+
4
+ // Defining a space for information and references about the module to be stored internally
5
+ VALUE MyTest = Qnil;
6
+
7
+ // Prototype for the initialization method - Ruby calls this, not you
8
+ void Init_mytest();
9
+
10
+ // Prototype for our method 'test1' - methods are prefixed by 'method_' here
11
+ VALUE method_test1(VALUE self);
12
+
13
+ // The initialization method for this module
14
+ void Init_mytest() {
15
+ MyTest = rb_define_module("MyTest");
16
+ rb_define_method(MyTest, "test1", method_test1, 0);
17
+ }
18
+
19
+ // Our 'test1' method.. it simply returns a value of '10' for now.
20
+ VALUE method_test1(VALUE self) {
21
+ int x = 10;
22
+ return INT2NUM(x);
23
+ }
24
+
25
+ VALUE method_aes_encrypt(VALUE value) {
26
+ return "ENCRYPTED%sENCRYPTED";
27
+ }
Binary file
@@ -0,0 +1,11 @@
1
+ # Loads mkmf which is used to make makefiles for Ruby extensions
2
+ require 'mkmf'
3
+
4
+ # Give it a name
5
+ extension_name = 'mytest'
6
+
7
+ # The destination
8
+ dir_config(extension_name)
9
+
10
+ # Do the work
11
+ create_makefile(extension_name)
Binary file
@@ -0,0 +1,8 @@
1
+ # Load in the extension (on OS X this loads ./MyTest/mytest.bundle - unsure about Linux, possibly mytest.so)
2
+ require_relative 'MyTest/mytest'
3
+
4
+ # MyTest is now a module, so we need to include it
5
+ include MyTest
6
+
7
+ # Call and print the result from the test1 method
8
+ puts test1
@@ -0,0 +1,208 @@
1
+ import httplib
2
+ import json
3
+
4
+ '''
5
+ GET UUID OF THE TARGET VAULT WE WANT TO DEAL WITH!
6
+ '''
7
+ class RestTester:
8
+
9
+ def create_vault(self):
10
+ request = {"name":"default","path":"/home/spacekookie/Desktop","passphrase":"peterpanistderheld"}
11
+ conn = httplib.HTTPConnection("localhost", 55736)
12
+ h = {'Content-Type':'application/json'}
13
+ conn.request("PUT","/vaults", json.dumps(request), h)
14
+ res = conn.getresponse()
15
+
16
+ data = {}
17
+ try:
18
+ data = json.loads(res.read())
19
+ except:
20
+ print "[FAILED]", "JSON was not readable for some reason", res.read()
21
+ return
22
+
23
+ print data['payload']
24
+
25
+ self.my_token = data['payload']
26
+ if self.my_token: success = "[PASS]\t"
27
+ else: success = "[FAIL]\t"
28
+
29
+ print success, "PUT /vaults", res.status, res.reason, ":'%s'" % data['message']
30
+
31
+ def available_vaults(self):
32
+ target_vault = 'default'
33
+ conn = httplib.HTTPConnection("localhost", 55736)
34
+ conn.request("GET","/vaults")
35
+ res = conn.getresponse()
36
+
37
+ print "[PASS]\t", "GET /vaults Response", res.status, res.reason
38
+ self.vaults = json.loads(res.read())
39
+
40
+ self.uuid = ''
41
+ for k, v in self.vaults['payload'].iteritems():
42
+ if v['name'] == target_vault: self.uuid = k
43
+
44
+
45
+ ''' REQUEST TOKEN '''
46
+ def request_token(self):
47
+ conn = httplib.HTTPConnection("localhost", 55736)
48
+ header = {'Content-Type':'application/json'}
49
+ token_body = {'passphrase':'peterpanistderheld'}
50
+ conn.request("POST","/vaults/%s/request_token" % self.uuid, json.dumps(token_body), header)
51
+ res = conn.getresponse()
52
+
53
+ data = None
54
+ try:
55
+ data = json.loads(res.read())
56
+ except:
57
+ print res.read()
58
+
59
+
60
+ if data and data['success']: success = "[PASS]\t"
61
+ else: success = "[FAIL]\t"
62
+
63
+ print success, "POST /vaults/UUID/request_token", res.status, res.reason, ":'%s'" % data['message']
64
+ self.my_token = data['payload']
65
+ print self.my_token
66
+
67
+
68
+ ''' FREE TOKEN '''
69
+ def free_token(self):
70
+ conn = httplib.HTTPConnection("localhost", 55736)
71
+ header = {'Content-Type':'application/json'}
72
+ token_body = {'token':self.my_token}
73
+ conn.request("POST","/vaults/%s/free_token" % self.uuid, json.dumps(token_body), header)
74
+ res = conn.getresponse()
75
+ data = json.loads(res.read())
76
+
77
+ if data['success']: success = "[PASS]\t"
78
+ else: success = "[FAIL]\t"
79
+ print success, "POST /vaults/UUID/free_token", res.status, res.reason, ":'%s'" % data['message']
80
+ self.my_token = None
81
+
82
+
83
+ def get_headers(self):
84
+ conn = httplib.HTTPConnection("localhost", 55736)
85
+ header = {'Content-Type':'application/json'}
86
+ token_body = {'token':self.my_token}
87
+ conn.request("POST","/vaults/%s/headers" % self.uuid, json.dumps(token_body), header)
88
+ res = conn.getresponse()
89
+ data = json.loads(res.read())
90
+
91
+ if data['success']: success = "[PASS]\t"
92
+ else: success = "[FAIL]\t"
93
+
94
+ print success, "POST /vaults/UUID/headers", res.status, res.reason, ":'%s'" % data['message']
95
+ self.headers = data['payload']
96
+
97
+ def close_vault(self):
98
+ conn = httplib.HTTPConnection("localhost", 55736)
99
+ header = {'Content-Type':'application/json'}
100
+ token_body = {'token':self.my_token}
101
+ conn.request("POST","/vaults/%s/close" % self.uuid, json.dumps(token_body), header)
102
+ res = conn.getresponse()
103
+ data = json.loads(res.read())
104
+
105
+ if data['success']: success = "[PASS]\t"
106
+ else: success = "[FAIL]\t"
107
+
108
+ print success, "POST /vaults/UUID/close", res.status, res.reason, ":'%s'" % data['message']
109
+ self.close_code = data['payload']
110
+
111
+
112
+ def insert_file(self):
113
+ conn = httplib.HTTPConnection("localhost", 55736)
114
+ header = {'Content-Type':'application/json'}
115
+ token_body = {'name':'MyFace', 'token':self.my_token, 'data':{'body':{'username':'spacekookie', 'passphrase':'abcdefghijklmnop'}, 'header':{'urls':['www.myface.com']}}}
116
+ conn.request("PUT","/vaults/%s/files" % self.uuid, json.dumps(token_body), header)
117
+ res = conn.getresponse()
118
+ data = json.loads(res.read())
119
+
120
+ if data['success']: success = "[PASS]\t"
121
+ else: success = "[FAIL]\t"
122
+
123
+ self.test_file = data['payload']['file_handle']
124
+ print success, "PUT /vaults/UUID/files", res.status, res.reason, ":'%s'" % data['message']
125
+
126
+ def update_file(self):
127
+ print self.my_token
128
+
129
+ conn = httplib.HTTPConnection("localhost", 55736)
130
+ header = {'Content-Type':'application/json'}
131
+ token_body = {'token':self.my_token, 'data':{'body':{'note':'This is an awesome social network that combines facebook with myspace. MYFACE!', 'passphrase':'lkj23l4kj23lkj234'}, 'header':{'tags':['social', 'hipster', 'awesome']}}}
132
+ conn.request("POST","/vaults/%s/files/%s" % (self.uuid, self.test_file), json.dumps(token_body), header)
133
+ res = conn.getresponse()
134
+
135
+ raw = res.read()
136
+ data = json.loads(raw)
137
+
138
+ if data['success']: success = "[PASS]\t"
139
+ else: success = "[FAIL]\t"
140
+ print success, "POST /vaults/UUID/files", res.status, res.reason, ":'%s'" % data['message']
141
+
142
+
143
+ def get_file_body(self):
144
+ conn = httplib.HTTPConnection("localhost", 55736)
145
+ header = {'Content-Type':'application/json'}
146
+ token_body = {'token':self.my_token}
147
+ conn.request("POST","/vaults/%s/files/%s" % (self.uuid, self.test_file), json.dumps(token_body), header)
148
+ res = conn.getresponse()
149
+ data = json.loads(res.read())
150
+
151
+ template = {'header':{'tags':['social', 'hipster', 'awesome'], 'urls':['www.myface.com']}, 'body':{'passphrase':'lkj23l4kj23lkj234', 'note':'This is an awesome social network that combines facebook with myspace. MYFACE!', 'username':'spacekookie'}}
152
+
153
+ success = ''
154
+ if data['success']:
155
+ if data == template:
156
+ success = "[PASS]\t"
157
+ else:
158
+ success = "[FAIL]\t"
159
+ print success, "PUT /vaults/UUID/files", res.status, res.reason, ":'%s'" % data['message']
160
+
161
+
162
+ def get_file_history(self):
163
+ conn = httplib.HTTPConnection("localhost", 55736)
164
+ header = {'Content-Type':'application/json'}
165
+ token_body = {'token':self.my_token}
166
+ conn.request("POST","/vaults/%s/files/%s/history" % (self.uuid, self.test_file), json.dumps(token_body), header)
167
+ res = conn.getresponse()
168
+ data = json.loads(res.read())
169
+
170
+ if data['success']:
171
+ success = "[PASS]\t"
172
+ else: success = "[FAIL]\t"
173
+ print success, "PUT /vaults/UUID/files", res.status, res.reason, ":'%s'" % data['message'], data['payload']
174
+
175
+
176
+ def __init__(self):
177
+ # Create a vault and get a token
178
+ # self.create_vault()
179
+
180
+ # Free the token again to test
181
+
182
+ # Get available vaults (self.vaults)
183
+ self.available_vaults()
184
+
185
+ # Now get a new token (self.my_token)
186
+ self.request_token()
187
+
188
+ # self.free_token()
189
+ # Get headers (fills self.headers)
190
+ # self.get_headers()
191
+
192
+ # Insert a new file
193
+ # self.insert_file()
194
+
195
+ # Then update it
196
+ # self.update_file()
197
+
198
+ # Then return the file and mirror it with what it should be
199
+ # self.get_file_body()
200
+
201
+ # Then check the versioning history matches
202
+ # self.get_file_history()
203
+
204
+ # Close the vault
205
+ # self.close_vault()
206
+
207
+
208
+ rt = RestTester()
data/tests/play.rb CHANGED
@@ -1,5 +1,61 @@
1
- require 'aes'
1
+ hash = { 'something' => 5, 'other' => 6 }
2
2
 
3
- k = AES.key
4
- data = AES.encrypt(k, "this_is_my_mega_secure_penis_i_mean_password_yo_bitch")
5
- File.open("readme", "wb").write(Base64.encode64(data))
3
+ puts hash
4
+
5
+ hash.each { |key, val| hash.delete(key) if key == 'other' }
6
+
7
+ puts hash
8
+
9
+ # def user_code
10
+ # 10.times do |x|
11
+ # puts 'I am user code'
12
+ # something_to_debounce
13
+ # sleep(1)
14
+ # end
15
+ # end
16
+ #
17
+ # class Debouncer
18
+ #
19
+ # attr_accessor :var
20
+ #
21
+ # def initialize
22
+ # @var = 0
23
+ # end
24
+ #
25
+ # def update
26
+ # @var += 1
27
+ # end
28
+ #
29
+ # def debouncer
30
+ # last = Time.new
31
+ # 11.times do
32
+ # tmp = Time.new
33
+ # r_delta = tmp - last
34
+ # last =tmp
35
+ # puts "Debouncer no #{var}\nDelta: #{r_delta}"
36
+ # sleep(1.00001)
37
+ # end
38
+ # end
39
+ # end
40
+ #
41
+ # def something_to_debounce
42
+ # @bouncer.update
43
+ # end
44
+ #
45
+ # def init(options, &block)
46
+ # print options
47
+ #
48
+ # puts 'Ich bin Reedb setup code'
49
+ #
50
+ # @bouncer = Debouncer.new
51
+ #
52
+ # t2 = Thread.new { @bouncer.debouncer }
53
+ # t1 = Thread.new(&block)
54
+ #
55
+ # t2.join
56
+ # t1.join
57
+ #
58
+ # puts ' => Everything is dead'
59
+ # end
60
+ #
61
+ # init(0) { user_code }