dbox 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +0,0 @@
1
- F LICENSE eee4b82f8ec32762095d12613d633f24ac242ebe
2
- F README da39a3ee5e6b4b0d3255bfef95601890afd80709
3
- F Rakefile 30ac5c2002b9bccb9064e956fefa88f687e6d719
4
- F config/testing.json.example 4f833212f80566278dfe78c216f05f16db92ce4d
5
- F example/test_pingback.rb 082e0b515333e3c495e1b3cbce179a4e7c69bd6b
6
- F lib/dropbox.rb d7d8960fb725f046b83f17fe54f64f603fbb2cf6
7
- F test/authenticator_test.rb b476e8fbbaa73cf6d1db227c549e43860e85f60b
8
- F test/client_test.rb aa34080cc5dcb369d39f0fa4c602be89100a535b
9
- F test/util.rb 0d49786886f9aee3b2f60ba1f56e7f861b3480b4
@@ -1,53 +0,0 @@
1
- require 'rubygems'
2
- require 'lib/dropbox'
3
- require 'test/unit'
4
- require 'shoulda'
5
- require './test/util'
6
-
7
- CONF = Authenticator.load_config("config/testing.json")
8
-
9
- class AuthenticatorTest < Test::Unit::TestCase
10
- context "Authenticator" do
11
- should "load json config" do
12
- assert CONF
13
- auth = Authenticator.new(CONF)
14
- end
15
-
16
- should "get request token" do
17
- auth = Authenticator.new(CONF)
18
- authorize_url = auth.get_request_token
19
- assert authorize_url
20
- end
21
-
22
- should "get access token" do
23
- auth = Authenticator.new(CONF)
24
- authorize_url = auth.get_request_token
25
- assert authorize_url
26
-
27
- login_and_authorize(authorize_url, CONF)
28
-
29
- access_token = auth.get_access_token
30
- assert access_token
31
-
32
- assert access_token.token
33
- assert access_token.secret
34
-
35
- CONF['access_token_key'] = access_token.token
36
- CONF['access_token_secret'] = access_token.secret
37
-
38
- response = access_token.get "http://" + CONF['server'] + "/0/oauth/echo"
39
- assert response
40
- assert response.code == "200"
41
- end
42
-
43
- should "reuse an existing token" do
44
- auth = Authenticator.new(CONF, CONF['access_token_key'], CONF['access_token_secret'])
45
- access_token = auth.get_access_token
46
-
47
- response = access_token.get "http://" + CONF['server'] + "/0/oauth/echo"
48
- assert response
49
- assert response.code == "200"
50
- end
51
- end
52
- end
53
-
@@ -1,100 +0,0 @@
1
- require 'rubygems'
2
- require 'lib/dropbox'
3
- require 'test/unit'
4
- require 'shoulda'
5
- require './test/util'
6
- require 'pp'
7
-
8
- CONF = Authenticator.load_config("config/testing.json") unless defined?(CONF)
9
- AUTH = Authenticator.new(CONF) unless defined?(AUTH)
10
- login_and_authorize(AUTH.get_request_token, CONF)
11
- ACCESS_TOKEN = AUTH.get_access_token
12
-
13
-
14
- class DropboxClientTest < Test::Unit::TestCase
15
-
16
- context "DropboxClient" do
17
- setup do
18
- assert ACCESS_TOKEN
19
- assert AUTH
20
- assert CONF
21
-
22
- begin
23
- client = DropboxClient.new(CONF['server'], CONF['content_server'], CONF['port'], AUTH)
24
- client.file_delete(CONF['root'], "/tests")
25
- rescue
26
- # ignored
27
- end
28
- end
29
-
30
- should "be able to access account info" do
31
- client = DropboxClient.new(CONF['server'], CONF['content_server'], CONF['port'], AUTH)
32
- info = client.account_info
33
- assert info
34
- assert info["country"]
35
- assert info["uid"]
36
- end
37
-
38
- should "build full urls" do
39
- client = DropboxClient.new(CONF['server'], CONF['content_server'], CONF['port'], AUTH)
40
- url = client.build_url(CONF['server'], CONF['port'], "/account/info")
41
- assert_equal url, "http://" + CONF['server'] + "/0/account/info"
42
-
43
- url = client.build_url(CONF['server'], CONF['port'], "/account/info")
44
- assert_equal url, "http://" + CONF['server'] + "/0/account/info"
45
-
46
- url = client.build_url(CONF['server'], CONF['port'], "/account/info", params={"one" => "1", "two" => "2"})
47
- assert_equal url, "http://" + CONF['server'] + "/0/account/info?two=2&one=1"
48
-
49
- url = client.build_url(CONF['server'], CONF['port'], "/account/info", params={"one" => "1", "two" => "2"})
50
- assert_equal url, "http://" + CONF['server'] + "/0/account/info?two=2&one=1"
51
- end
52
-
53
-
54
- should "create links" do
55
- client = DropboxClient.new(CONF['server'], CONF['content_server'] ,CONF['port'], AUTH)
56
- assert_equal "http://" + CONF['server'] + "/0/links/" + CONF['root'] + "/to/the/file", client.links(CONF['root'], "/to/the/file")
57
- end
58
-
59
- should "get metadata" do
60
- client = DropboxClient.new(CONF['server'], CONF['content_server'] ,CONF['port'], AUTH)
61
- results = client.metadata(CONF['root'], "/")
62
- assert results
63
- assert results["hash"]
64
- end
65
-
66
- should "be able to perform file ops on folders" do
67
- client = DropboxClient.new(CONF['server'], CONF['content_server'], CONF['port'], AUTH)
68
- results = client.file_create_folder(CONF['root'], "/tests/that")
69
- assert results
70
- assert results["bytes"]
71
-
72
- assert client.file_copy(CONF['root'], "/tests/that", "/tests/those")
73
- assert client.metadata(CONF['root'], "/tests/those")
74
- assert client.file_delete(CONF['root'], "/tests/those")
75
-
76
- results = client.file_move(CONF['root'], "/tests/that", "/tests/those")
77
- assert results
78
-
79
- assert client.metadata(CONF['root'], "/tests/those")
80
- assert client.file_delete(CONF['root'], "/tests/those")
81
-
82
- end
83
-
84
- should "be able to get files" do
85
- client = DropboxClient.new(CONF['server'], CONF['content_server'], CONF['port'], AUTH)
86
- results = client.get_file(CONF['root'], "/client_tests.py")
87
- assert results
88
- end
89
-
90
- should "be able to put files" do
91
- client = DropboxClient.new(CONF['server'], CONF['content_server'], CONF['port'], AUTH)
92
- results = client.put_file(CONF['root'], "/", "LICENSE", open("LICENSE"))
93
- assert results
94
- assert client.file_delete(CONF['root'], "/LICENSE")
95
- end
96
-
97
- end
98
-
99
- end
100
-
@@ -1,21 +0,0 @@
1
- require 'mechanize'
2
-
3
-
4
-
5
- def login_and_authorize(authorize_url, config)
6
- a = WWW::Mechanize.new
7
- a.get(authorize_url) do |page|
8
- login_form = page.form_with(:action => '/login')
9
-
10
- login_form.login_email = config['testing_user']
11
- login_form.login_password = config['testing_password']
12
- auth_page = login_form.submit()
13
-
14
- auth_form = auth_page.form_with(:action => 'authorize')
15
- if auth_form
16
- auth_button = auth_form.button_with(:value => "Allow")
17
- auth_form.click_button
18
- end
19
-
20
- end
21
- end