cloudfs 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,194 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe CloudFS::Item do
4
+ before do
5
+ session = CloudFS::Session.new(Configuration::HOST, Configuration::CLIENT_ID, Configuration::SECRET)
6
+ session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
7
+ @subject = session.filesystem
8
+ @test_folder = @subject.root.create_folder(Configuration::TEST_FOLDER, exists: 'OVERWRITE')
9
+ @folder = @test_folder.create_folder('item_test_folder', exists: 'OVERWRITE')
10
+ @file = @folder.upload('item test', name: 'item_test_file.txt', exists: 'OVERWRITE', upload_io: true)
11
+ end
12
+
13
+ it 'should have an id' do
14
+ @folder.id.wont_be_empty
15
+ @file.id.wont_be_empty
16
+ end
17
+
18
+ describe 'get path' do
19
+ it '#path' do
20
+ @folder.path.wont_be_empty
21
+ @file.path.wont_be_empty
22
+ end
23
+ end
24
+
25
+ describe 'get type' do
26
+ it '#path' do
27
+ @folder.type.must_equal 'folder'
28
+ @file.type.must_equal 'file'
29
+ end
30
+ end
31
+
32
+ describe 'is mirrored' do
33
+ it '#mirrored' do
34
+ # @folder.is_mirrored.must_be_instance_of boolean
35
+ # @file.is_mirrored.must_be_instance_of boolean
36
+ end
37
+ end
38
+
39
+ describe 'get date content last modified' do
40
+ it '#date content last modified' do
41
+ @folder.date_content_last_modified.wont_be_nil
42
+ @file.date_content_last_modified.must_be_instance_of Time
43
+ end
44
+ end
45
+
46
+ describe 'get date created' do
47
+ it '#date created' do
48
+ @folder.date_created.wont_be_nil
49
+ @file.date_created.must_be_instance_of Time
50
+ end
51
+ end
52
+
53
+ describe 'get date meta last modified' do
54
+ it '#date meta last modified' do
55
+ @folder.date_meta_last_modified.wont_be_nil
56
+ @file.date_meta_last_modified.must_be_instance_of Time
57
+ end
58
+ end
59
+
60
+ describe 'get name' do
61
+ it '#name' do
62
+ @folder.name.must_equal 'item_test_folder'
63
+ @file.name.must_equal 'item_test_file.txt'
64
+ end
65
+ end
66
+
67
+ describe 'get application data' do
68
+ it '# get application data' do
69
+ @folder.application_data.wont_be_nil
70
+ @file.application_data.wont_be_nil
71
+ end
72
+ end
73
+
74
+ describe 'set name' do
75
+ it '#new name' do
76
+ @folder.name =('item_test_folder_001')
77
+
78
+ @file.name = ('item_test_file_001')
79
+
80
+ @new_folder = @subject.get_item(@folder.path)
81
+ @new_folder.name.must_equal 'item_test_folder_001'
82
+
83
+ @new_file = @subject.get_item(@file.path)
84
+ @new_file.name.must_equal 'item_test_file_001'
85
+ end
86
+
87
+ after do
88
+ @new_folder.delete(commit: true, force: true)
89
+ @new_file.delete(commit: true)
90
+ end
91
+
92
+ end
93
+
94
+ describe 'set application data' do
95
+ it '#set application data' do
96
+ application_data = @file.application_data
97
+ @file.application_data = (application_data)
98
+ end
99
+ end
100
+
101
+ describe 'change attributes' do
102
+ it '#change attributes' do
103
+ folder_attributes = Hash.new
104
+ folder_attributes[:name] = 'changed_folder_name'
105
+ folder_result = @folder.change_attributes(** folder_attributes)
106
+ @updated_folder = @subject.get_item(@folder.path)
107
+
108
+ @updated_folder.name.must_equal 'changed_folder_name'
109
+ folder_result.must_equal true
110
+
111
+ file_attributes = Hash.new
112
+ file_attributes[:name] = 'changed_file_name.txt'
113
+ file_result = @file.change_attributes(** file_attributes)
114
+ @updated_file = @subject.get_item(@file.path)
115
+
116
+ @updated_file.name.must_equal 'changed_file_name.txt'
117
+ file_result.must_equal true
118
+ end
119
+ after do
120
+ @updated_folder.delete(commit: true, force: true)
121
+ @updated_file.delete(commit: true)
122
+ end
123
+ end
124
+
125
+ describe 'delete folder' do
126
+ it '#delete folder' do
127
+ file_result = @file.delete(commit: true, force: true)
128
+ file_result.must_equal true
129
+
130
+ folder_result = @folder.delete(commit: true, force: true)
131
+ folder_result.must_equal true
132
+ end
133
+ end
134
+
135
+ describe 'moving items' do
136
+ before do
137
+ @move_target = @test_folder.create_folder('move_test_target')
138
+ @move_source = @test_folder.create_folder('move_test_source')
139
+ @move_file_source = @folder.upload('item move test', name: 'item_move_test_file.txt', exists: 'OVERWRITE', upload_io: true)
140
+ end
141
+
142
+ it '#move' do
143
+ @move_source.move(@move_target.path)
144
+ @move_file_source.move(@move_source.path)
145
+ @move_target.list.length.must_equal 1
146
+ @move_source.list.length.must_equal 1
147
+ end
148
+
149
+ after do
150
+ @move_target.delete(commit: true, force: true)
151
+ @move_source.delete(commit: true)
152
+ end
153
+ end
154
+
155
+ describe 'copying items' do
156
+ before do
157
+ @copy_target = @test_folder.create_folder('copy_test_target')
158
+ @copy_source = @test_folder.create_folder('copy_test_source')
159
+ @copy_folder = @copy_source.create_folder('copy_item1')
160
+ @copy_file_source = @copy_source.upload('item copy test', name: 'item_copy_test_file.txt', exists: 'OVERWRITE', upload_io: true)
161
+
162
+ end
163
+
164
+ it '#copy' do
165
+ @copy_folder.copy(@copy_target.path)
166
+ @copy_file_source.copy(@copy_target.path)
167
+
168
+ @copy_target.list.length.must_equal 2
169
+ @copy_source.list.length.must_equal 2
170
+ end
171
+
172
+ after do
173
+ @copy_target.delete(commit: true, force: true)
174
+ @copy_source.delete(commit: true)
175
+ end
176
+ end
177
+
178
+ describe 'restore' do
179
+ it '#restore' do
180
+ @delete_test = @test_folder.create_folder('delete_folder')
181
+ @delete_folder = @delete_test.create_folder('new_folder')
182
+ @delete_file = @delete_test.upload('item delete test', name: 'item_delete_test_file.txt', exists: 'OVERWRITE', upload_io: true)
183
+
184
+ @delete_file.delete
185
+ @delete_folder.delete
186
+
187
+ @delete_folder.restore(@delete_folder.path, restore_argument: true)
188
+ @delete_file.restore(@delete_file.path, restore_argument: true)
189
+
190
+ @delete_test.list.length.must_equal 2
191
+ end
192
+ end
193
+
194
+ end
@@ -0,0 +1,102 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe CloudFS::Session do
4
+ before do
5
+ @session = CloudFS::Session.new(Configuration::HOST, Configuration::CLIENT_ID, Configuration::SECRET)
6
+ end
7
+
8
+ it 'initializing session' do
9
+ @session.wont_be_nil
10
+ end
11
+
12
+ describe 'authenticating session' do
13
+ before do
14
+ @auth_status = @session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
15
+ end
16
+ it '#authenticatesession' do
17
+ @auth_status.wont_be_nil
18
+ @auth_status.must_equal true
19
+ end
20
+ end
21
+
22
+ describe 'get user' do
23
+ before do
24
+ @auth_status = @session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
25
+ end
26
+ it '#getuser' do
27
+ @authenticated_user = @session.user
28
+ @authenticated_user_name = @authenticated_user.username
29
+ @authenticated_user.wont_be_nil
30
+ @authenticated_user_name.must_equal Configuration::USERNAME
31
+ end
32
+ end
33
+
34
+ describe 'get filesystem' do
35
+ before do
36
+ @auth_status = @session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
37
+ end
38
+ it '#getfilesystem' do
39
+ @file_system = @session.filesystem
40
+ @root_name = @file_system.root.name
41
+ @file_system.wont_be_nil
42
+ @root_name.must_equal 'root'
43
+ end
44
+ end
45
+
46
+ describe 'get account' do
47
+ before do
48
+ @auth_status = @session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
49
+ end
50
+ it '#getaccount' do
51
+ @account_object = @session.account
52
+ @account_id = @account_object.id
53
+ @account_object.wont_be_nil
54
+ @account_id.must_be_instance_of String
55
+ @account_id.length.must_equal 36
56
+ end
57
+ end
58
+
59
+ describe 'is linked' do
60
+ before do
61
+ @auth_status = @session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
62
+ end
63
+ it '#islinked' do
64
+ @is_linked = @session.is_linked?
65
+ @is_linked.must_equal true
66
+ end
67
+ end
68
+
69
+ describe 'unlink session' do
70
+ before do
71
+ @auth_status = @session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
72
+ end
73
+ it '#unlink' do
74
+ @unlink_status = @session.unlink
75
+ @unlink_status.must_equal true
76
+ end
77
+ end
78
+
79
+ describe 'action history' do
80
+ before do
81
+ @auth_status = @session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
82
+ end
83
+ it '#actionhistory' do
84
+ @action_history = @session.action_history
85
+ @action_history.wont_be_nil
86
+ @action_history.must_be_instance_of Array
87
+ end
88
+ end
89
+
90
+ # Disabling this test to prevent creating new accounts.
91
+ #
92
+ # describe 'create account' do
93
+ # it '#createaccount' do
94
+ #
95
+ # @session.set_admin_credentials(Configuration::ADMIN_ID, Configuration::ADMIN_SECRET)
96
+ # @created_account = @session.create_account('test@gmail.com','user@123', email:'test@gmail.com',
97
+ # first_name:'test', last_name:'lastname')
98
+ # end
99
+ #
100
+ # end
101
+
102
+ end
@@ -0,0 +1,159 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe CloudFS::Share do
4
+ before do
5
+ session = CloudFS::Session.new(Configuration::HOST, Configuration::CLIENT_ID, Configuration::SECRET)
6
+ session.authenticate(Configuration::USERNAME, Configuration::PASSWORD)
7
+ @subject = session.filesystem
8
+ @test_folder = @subject.root.create_folder(Configuration::TEST_FOLDER, exists: 'OVERWRITE')
9
+ @test_share_folder = @test_folder.create_folder('share_test')
10
+ @test_file = @test_share_folder.upload('share file content', name: 'share_file.txt', upload_io: true)
11
+ @share_file = @subject.create_share(@test_file.path)
12
+ @shared_folder_name1 = 'share_folder_001'
13
+ @shared_folder_name2 = 'share_folder_002'
14
+ end
15
+
16
+ after do
17
+ @test_share_folder.delete
18
+ end
19
+
20
+ describe 'Getting Share Key' do
21
+ it '#share_key' do
22
+ # @share_key = @share_file.share_key
23
+ # @share_key.wont_be_empty
24
+ end
25
+ end
26
+
27
+ describe 'Getting Name' do
28
+ it '#name' do
29
+ @share_name = @share_file.name
30
+ @share_name.wont_be_empty
31
+ end
32
+ end
33
+
34
+ describe 'Get Size' do
35
+ it '#size' do
36
+ @share_size = @share_file.size
37
+ @share_size.must_equal 18
38
+ end
39
+ end
40
+
41
+ describe 'List Share' do
42
+ it '#list' do
43
+ @share_list = @share_file.list
44
+ @share_list.must_be_instance_of Array
45
+ @share_list.length.must_equal 1
46
+ end
47
+ end
48
+
49
+ describe 'Receive Share File' do
50
+ before do
51
+ @share_download_folder = @test_folder.create_folder('share_download')
52
+ end
53
+
54
+ it '#receive' do
55
+ @receive_file = @share_file.receive(path: @share_download_folder.path)
56
+ @receive_file.must_be_instance_of Array
57
+ @receive_file.length.must_equal 1
58
+ end
59
+
60
+ after do
61
+ @share_download_folder.delete
62
+ end
63
+ end
64
+
65
+ describe 'Set Share Password' do
66
+ it '#set_password' do
67
+ @share_file = @share_file.set_password('user@123')
68
+ @share_file = @share_file.set_password('user@1234', current_password: 'user@123')
69
+ end
70
+ end
71
+
72
+ describe 'Delete Share' do
73
+ it '#delete' do
74
+ @status = @share_file.delete
75
+ @status.must_equal true
76
+ end
77
+ end
78
+
79
+ describe 'create share and related functions' do
80
+ before do
81
+ @shared_folder = @subject.root.create_folder('shared_folder', exists: 'OVERWRITE')
82
+ @share_instance = @subject.create_share(@shared_folder.path)
83
+ end
84
+ it '#sharing functions' do
85
+ @share_instance.name.must_equal 'share'
86
+
87
+ attributes = Hash.new
88
+ attributes['name'] = @shared_folder_name1
89
+ attributes['password'] = 'newPassword'
90
+ @share_instance.set_password('password')
91
+ result = @share_instance.change_attributes(attributes, password: 'password')
92
+
93
+ share_list = @subject.list_shares
94
+ share_list.each do |item|
95
+ if item.name == @shared_folder_name1
96
+ @share_instance = item
97
+ end
98
+ end
99
+
100
+ result.must_equal true
101
+ @share_instance.name.must_equal @shared_folder_name1
102
+
103
+
104
+ @share_instance.set_name(@shared_folder_name2, password: 'newPassword')
105
+
106
+ share_list = @subject.list_shares
107
+ share_list.each do |item|
108
+ if item.name == @shared_folder_name2
109
+ @share_instance = item
110
+ end
111
+ end
112
+
113
+ @share_instance.name.must_equal @shared_folder_name2
114
+ end
115
+ after do
116
+ @shared_folder.delete(commit: true, force: true)
117
+ end
118
+ end
119
+
120
+ describe 'multiple shares' do
121
+ it '#should be able to share multiple items' do
122
+ @folder_01 = @subject.root.create_folder('folder_01', exists: 'OVERWRITE')
123
+ @folder_02 = @subject.root.create_folder('folder_02', exists: 'OVERWRITE')
124
+
125
+ folder_list = [@folder_01.path, @folder_02.path]
126
+ @folder_share = @subject.create_share(folder_list)
127
+
128
+ @folder_share.list.length.must_equal 2
129
+ end
130
+ after do
131
+ @folder_01.delete(commit: true, force: true)
132
+ @folder_02.delete(commit: true, force: true)
133
+ end
134
+ end
135
+
136
+ describe 'Listing the shared folder content and traversing' do
137
+ before do
138
+ @share_root = @test_folder.create_folder('share_root', exists: 'OVERWRITE')
139
+ @share_child_01 = @share_root.create_folder('share_child_01', exists: 'OVERWRITE')
140
+ @share_child_01.upload('share child 01 content', name: 'share_child_01.txt', upload_io: true)
141
+ @shared_root_folder = @subject.create_share(@share_root.path)
142
+ end
143
+
144
+ it 'Should show the child folders and files' do
145
+ shared_root_content = @shared_root_folder.list
146
+ shared_root_content.length.must_equal 1
147
+ shared_root_content.first.name.must_equal 'share_child_01'
148
+
149
+ shared_child_content = shared_root_content.first.list
150
+ shared_child_content.length.must_equal 1
151
+ shared_child_content.first.name.must_equal 'share_child_01.txt'
152
+ end
153
+
154
+ after do
155
+ @share_root.delete(commit: true, force: true)
156
+ end
157
+ end
158
+
159
+ end