nvx-sds 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +64 -0
- data/README +80 -0
- data/lib/nvx/sds/APIClasses/accountfeatureusage.rb +60 -0
- data/lib/nvx/sds/APIClasses/accountinfo.rb +30 -0
- data/lib/nvx/sds/APIClasses/accountlimit.rb +25 -0
- data/lib/nvx/sds/APIClasses/contactinfo.rb +74 -0
- data/lib/nvx/sds/APIClasses/fsfileattributes.rb +50 -0
- data/lib/nvx/sds/APIClasses/fsfolderattributes.rb +53 -0
- data/lib/nvx/sds/APIClasses/fsfolderlist.rb +70 -0
- data/lib/nvx/sds/APIClasses/metadatainfo.rb +26 -0
- data/lib/nvx/sds/APIClasses/responsecodes.rb +97 -0
- data/lib/nvx/sds/APIClasses/soapupload.rb +52 -0
- data/lib/nvx/sds/APIClasses/utilities.rb +97 -0
- data/lib/nvx/sds/SOAP/TransferClient.rb +68 -0
- data/lib/nvx/sds/SOAP/default.rb +80 -0
- data/lib/nvx/sds/SOAP/defaultDriver.rb +70 -0
- data/lib/nvx/sds/accountlogin.rb +68 -0
- data/lib/nvx/sds/apicommand.rb +251 -0
- data/lib/nvx/sds/apiparam.rb +33 -0
- data/lib/nvx/sds/countries.rb +257 -0
- data/lib/nvx/sds/folder.rb +236 -0
- data/lib/nvx/sds/hosteditem.rb +115 -0
- data/lib/nvx/sds/itembase.rb +53 -0
- data/lib/nvx/sds/masteraccount.rb +74 -0
- data/lib/nvx/sds/nvxfile.rb +173 -0
- data/lib/nvx/sds/session.rb +110 -0
- data/lib/nvx/sds/transport.rb +129 -0
- data/lib/nvx_sds.rb +19 -0
- data/tests/TestUpload.txt +9 -0
- data/tests/accountlogintest.rb +19 -0
- data/tests/apicommandtest.rb +186 -0
- data/tests/apiparamtest.rb +24 -0
- data/tests/countriestest.rb +20 -0
- data/tests/foldertest.rb +26 -0
- data/tests/fsfolderlisttest.rb +127 -0
- data/tests/masteraccounttest.rb +69 -0
- data/tests/sessiontest.rb +187 -0
- data/tests/testconfig.rb +14 -0
- data/tests/transporttest.rb +19 -0
- data/tests/unittests_gemtest.rb +17 -0
- data/tests/uploadtest.rb +22 -0
- metadata +102 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
# = Overview
|
2
|
+
#
|
3
|
+
# The session is the primary object for interaction with the Gem. You will use the session to get the root folder and subsiquent
|
4
|
+
# IMFS objects and Accounting objects.
|
5
|
+
module NVX
|
6
|
+
module SDS
|
7
|
+
$:.unshift File.dirname(__FILE__)
|
8
|
+
require 'accountlogin'
|
9
|
+
require 'folder'
|
10
|
+
require 'apiclasses/utilities'
|
11
|
+
require 'hosteditem'
|
12
|
+
|
13
|
+
# The session is the primary object for interaction with the Gem. You will use the session to get the root folder and subsiquent
|
14
|
+
# IMFS objects and Accounting objects.
|
15
|
+
class Session
|
16
|
+
|
17
|
+
# Creates a new session object. The password is optional only when called to impersonate a child account.
|
18
|
+
# when creating a new session use the context:
|
19
|
+
# <b>session = Session.new("APPKEY", "USERNAME", "APPNAME", "PASSWORD")</b>
|
20
|
+
def initialize(appKey, username, appName, password = nil, session_token = nil)
|
21
|
+
@account_login = AccountLogin.new(appKey, username, appName, password, session_token)
|
22
|
+
@account_login.Login if session_token.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
# Gets the account login object.
|
26
|
+
def account_login
|
27
|
+
@account_login
|
28
|
+
end
|
29
|
+
|
30
|
+
# Sets the account login object.
|
31
|
+
def account_login=(account_login)
|
32
|
+
@account_login=account_login
|
33
|
+
end
|
34
|
+
|
35
|
+
# Logs the current user out ending the session.
|
36
|
+
def Logout
|
37
|
+
result = Transport.execute_command_post(APICommand.Logout, nil, @account_login)
|
38
|
+
@account_login = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
# Gets the root folder. You can use this to access all of the files and folders.
|
42
|
+
def GetRootFolder(page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true)
|
43
|
+
folder = Folder.ListFolder(@account_login, @account_login.root_path, page_number, page_size, folder_sort_code, should_sort_descending)
|
44
|
+
return folder
|
45
|
+
end
|
46
|
+
|
47
|
+
# Gets a specific folder based on the supplied path.
|
48
|
+
def GetFolder(path, page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true)
|
49
|
+
if path.index("//").nil?
|
50
|
+
path = @account_login.root_path + path
|
51
|
+
end
|
52
|
+
folder = Folder.ListFolder(@account_login, path, page_number, page_size, folder_sort_code, should_sort_descending)
|
53
|
+
return folder
|
54
|
+
end
|
55
|
+
|
56
|
+
# Gets the account information as an AccountInfo object from the current session user.
|
57
|
+
def GetAccountInfo
|
58
|
+
Utilities.GetAccountInfo(@account_login, @account_login.username)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Gets the account limits as an array of AccountLimit objects.
|
62
|
+
def GetAccountLimits
|
63
|
+
Utilities.GetAccountLimits(@account_login, @account_login.username)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Gets the account usage as an array of AccountFeatureUsage objects.
|
67
|
+
def GetAccountUsage
|
68
|
+
Utilities.GetAccountUsage(@account_login, @account_login.username)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Sets the account information for the current session user.
|
72
|
+
def SetAccountInfo(first_name, last_name, middle_initial, phone_number, email_address,
|
73
|
+
email_format, address_line1, address_line2, city, state, country, postal_code)
|
74
|
+
|
75
|
+
Utilities.SetAccountInfo(@account_login, @account_login.username, first_name, last_name,
|
76
|
+
middle_initial, phone_number, email_address, email_format, address_line1, address_line2,
|
77
|
+
city, state, country, postal_code)
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
# Deletes all the files from an array of strings passed.
|
82
|
+
def DeleteFiles(file_paths_to_delete)
|
83
|
+
params = Array.new
|
84
|
+
file_paths_to_delete.each do |path|
|
85
|
+
params << APIParam.new("filePath", path)
|
86
|
+
end
|
87
|
+
Transport.execute_command_post(APICommand.DeleteFiles, params, @account_login)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Deletes all the folders from an array of strings passed. <b>**THIS WILL REMOVE ALL SUB FOLDERS AND FILES AS WELL.</b>
|
91
|
+
def DeleteFolders(folder_paths_to_delete)
|
92
|
+
params = Array.new
|
93
|
+
folder_paths_to_delete.each do |path|
|
94
|
+
params << APIParam.new("folderPath", path)
|
95
|
+
end
|
96
|
+
Transport.execute_command_post(APICommand.DeleteFolders, params, @account_login)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns an array of hosted files and folders that have been hosted.
|
100
|
+
def ListHostedItems(page_number = 1, page_size = 500)
|
101
|
+
HostedItem.ListHostedItems(@account_login, page_number, page_size)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns the master account object.
|
105
|
+
def GetMasterAccount
|
106
|
+
MasterAccount.new(self, @account_login)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# = Overview
|
2
|
+
#
|
3
|
+
# The Transport is an internal class that handles the requests and responses from the Nirvanix REST web services.
|
4
|
+
# Requests can be made via HTTP GET or POST.
|
5
|
+
module NVX
|
6
|
+
module SDS
|
7
|
+
|
8
|
+
$:.unshift File.dirname(__FILE__)
|
9
|
+
require 'apiparam'
|
10
|
+
require 'apicommand'
|
11
|
+
require 'apiclasses/responsecodes'
|
12
|
+
require 'net/https'
|
13
|
+
require 'net/http'
|
14
|
+
require 'REXML/Document'
|
15
|
+
require 'uri'
|
16
|
+
|
17
|
+
Newline = "\r\n" unless const_defined? "Newline"
|
18
|
+
|
19
|
+
# = Overview
|
20
|
+
#
|
21
|
+
# This is an internal class that handles the requests and responses from the Nirvanix REST web services.
|
22
|
+
# Requests can be made via HTTP GET or POST.
|
23
|
+
class Transport
|
24
|
+
|
25
|
+
# A method to execute a nirvanix command with the parameters passed via a GET HTTP call.
|
26
|
+
# be aware that the parameters passed to this command will be limited in size due to the maximum
|
27
|
+
# url length allowed by http. With calls that require many parameters such as array be sure to use
|
28
|
+
# the post method.
|
29
|
+
def Transport.execute_command_get(apicommand, apiparams, account_login)
|
30
|
+
rest_api_url = "services.nirvanix.com"
|
31
|
+
webservice_root = "/ws/"
|
32
|
+
|
33
|
+
url = webservice_root + apicommand.command_path
|
34
|
+
|
35
|
+
apiparams = Array.new if apiparams.nil?
|
36
|
+
apiparams << APIParam.new("sessionToken", account_login.session_token) if !account_login.nil?
|
37
|
+
|
38
|
+
first = true
|
39
|
+
apiparams.each {|apiParam|
|
40
|
+
url = first == true ? url + '?' + apiParam.to_s : url + '&' + apiParam.to_s
|
41
|
+
first = false
|
42
|
+
}
|
43
|
+
|
44
|
+
#print "OUTPUT URL: " + url + "\r\n\r\n"
|
45
|
+
|
46
|
+
port = apicommand.is_secure? ? 443 : 80
|
47
|
+
|
48
|
+
http = Net::HTTP.new(rest_api_url, port)
|
49
|
+
http.use_ssl = apicommand.is_secure?
|
50
|
+
http.start do |http|
|
51
|
+
request = Net::HTTP::Get.new(url)
|
52
|
+
response = http.request(request)
|
53
|
+
response.value
|
54
|
+
#print "RESPONSE XML: " + response.body + "\r\n\r\n"
|
55
|
+
return REXML::Document.new(response.body)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# A method to execute a nirvanix command with the parameters passed via a POST HTTP call.
|
60
|
+
def Transport.execute_command_post(apicommand, apiparams, account_login)
|
61
|
+
rest_api_url = "services.nirvanix.com"
|
62
|
+
webservice_root = "/ws/"
|
63
|
+
|
64
|
+
url = webservice_root + apicommand.command_path
|
65
|
+
|
66
|
+
# add the session token in if valid.
|
67
|
+
apiparams = Array.new if apiparams.nil?
|
68
|
+
apiparams << APIParam.new("sessionToken", account_login.session_token) if !account_login.nil?
|
69
|
+
|
70
|
+
params = ""
|
71
|
+
first = true
|
72
|
+
apiparams.each do |apiParam|
|
73
|
+
params = first == true ? apiParam.to_s : params + '&' + apiParam.to_s
|
74
|
+
first = false
|
75
|
+
end
|
76
|
+
|
77
|
+
port = apicommand.is_secure? ? 443 : 80
|
78
|
+
|
79
|
+
# Create the first http(s) object.
|
80
|
+
h = Net::HTTP.new(rest_api_url, port)
|
81
|
+
|
82
|
+
# if you are just testing and do not have a SSL certificate setup properly you can
|
83
|
+
# disable warnings with the below line. Just uncomment to ignore SSL session warnings.
|
84
|
+
h.verify_mode = OpenSSL::SSL::VERIFY_NONE if apicommand.is_secure?
|
85
|
+
|
86
|
+
# put the SSL in the correct mode based on the apicommand
|
87
|
+
h.use_ssl = apicommand.is_secure?
|
88
|
+
|
89
|
+
# do the command and return the response.
|
90
|
+
response = h.post(url, params)
|
91
|
+
|
92
|
+
#print "OUTPUT URL: " + rest_api_url + url + "\r\n\r\n"
|
93
|
+
#print "RESPONSE XML: " + response.body + "\r\n\r\n"
|
94
|
+
|
95
|
+
doc = REXML::Document.new(response.body)
|
96
|
+
response_code = (text = doc.root.elements["//Response/ResponseCode"].get_text and text.value)
|
97
|
+
|
98
|
+
if response_code.to_i == SessionNotFound
|
99
|
+
# login and refresh session token
|
100
|
+
account_login.Login
|
101
|
+
# execute the command again so there is no interruption to the user.
|
102
|
+
return Transport.execute_command_post(apicommand, apiparams, account_login)
|
103
|
+
end
|
104
|
+
if response_code.to_i != 0
|
105
|
+
error_message = (text = doc.root.elements["//Response/ErrorMessage"].get_text and text.value)
|
106
|
+
raise error_message
|
107
|
+
end
|
108
|
+
return doc
|
109
|
+
end
|
110
|
+
|
111
|
+
# Retrieves a file from the remote server and saves it to the local file system
|
112
|
+
# The path can be relative or absolute, if you are a master account you can pass the absolute path
|
113
|
+
# to retrieve a child accounts file.
|
114
|
+
def Transport.DownloadFile(path, local_path, account_login)
|
115
|
+
# Get the download node this will get the proper node for a path.
|
116
|
+
doc = Transport.execute_command_post(APICommand.GetDownloadNodes, [APIParam.new("filePath", path)], account_login)
|
117
|
+
node = doc.root.elements["//Response/DownloadNode"].get_text.value
|
118
|
+
|
119
|
+
# Transfer the file to the local path.
|
120
|
+
Net::HTTP.start(node) do |http|
|
121
|
+
resp = http.get(path)
|
122
|
+
open(local_path, "wb") do |file|
|
123
|
+
file.write(resp.body)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/lib/nvx_sds.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# NVX-SDS: $Id:$
|
2
|
+
#
|
3
|
+
# Entry point to the framework.
|
4
|
+
# Loads all the files under the 'nvx/sds' subdirectory
|
5
|
+
require "rubygems"
|
6
|
+
|
7
|
+
here = File.dirname( __FILE__ )
|
8
|
+
dir = File.join( here , 'nvx/sds' )
|
9
|
+
require File.join( dir, "accountlogin" )
|
10
|
+
require File.join( dir, "apicommand" )
|
11
|
+
require File.join( dir, "apiparam" )
|
12
|
+
require File.join( dir, "countries" )
|
13
|
+
require File.join( dir, "folder" )
|
14
|
+
require File.join( dir, "session" )
|
15
|
+
require File.join( dir, "transport" )
|
16
|
+
require File.join( dir, "masteraccount" )
|
17
|
+
require File.join( dir, "apiclasses/soapupload" )
|
18
|
+
require File.join( dir, "apiclasses/fsfolderlist" )
|
19
|
+
require File.join( dir, "apiclasses/metadatainfo" )
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas eget odio. Ut dignissim, lorem et tincidunt bibendum, neque augue vulputate metus, sit amet varius libero enim ac ligula. Proin malesuada condimentum nibh. Proin in erat. Sed tincidunt augue ac nunc. Suspendisse potenti. Mauris dignissim sem tincidunt urna. Vivamus nec arcu. Vivamus odio ligula, imperdiet ut, posuere a, ultricies in, erat. Etiam dictum est in nulla. Nulla rhoncus. Cras justo velit, consectetuer sit amet, posuere vitae, porta sit amet, neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque imperdiet, turpis et vulputate suscipit, ipsum lorem varius risus, eget congue lacus ligula vel turpis. Curabitur lacus lorem, pulvinar non, vulputate vitae, interdum eu, turpis. Nam sem.
|
2
|
+
|
3
|
+
Proin quis arcu. Vivamus porta, mauris id tincidunt luctus, massa purus elementum tellus, dictum sollicitudin mauris turpis vitae erat. Etiam sem. Fusce arcu. In lobortis elit ut augue. Nunc nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque sapien. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam vitae est non mauris tempus vehicula. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
4
|
+
|
5
|
+
Vivamus dignissim lectus at dolor. Maecenas ac risus. Morbi in enim. Duis ac mi vel velit vehicula venenatis. Ut erat. Suspendisse arcu orci, ullamcorper eget, rutrum ac, bibendum pretium, orci. Etiam sodales tempor nulla. Cras vitae purus et pede accumsan ultricies. Nullam lacus. Curabitur dapibus ante non pede. Fusce eget arcu. Nulla facilisi. Vivamus sed pede. Pellentesque vehicula, erat at volutpat auctor, enim massa volutpat justo, sed malesuada nulla turpis sed purus. Cras egestas, ligula eu condimentum tincidunt, diam massa euismod pede, eget vulputate odio dolor luctus mi. Vivamus lacinia tortor non dui. Proin sem magna, aliquam ac, mollis sit amet, laoreet vitae, est. Donec sed urna eu augue vestibulum feugiat. Aliquam tellus velit, vestibulum vel, dapibus bibendum, mattis id, nisi.
|
6
|
+
|
7
|
+
Ut et urna a quam rhoncus eleifend. Maecenas a mauris. Fusce vestibulum nulla vitae enim. Etiam nec ante. Maecenas ornare, magna vitae nonummy aliquam, lacus purus porttitor tortor, sit amet lacinia magna dolor quis sapien. Duis ornare, est at rhoncus ultrices, odio turpis viverra ante, non pulvinar odio erat ac purus. Integer nunc est, condimentum vel, interdum ac, adipiscing id, quam. Aliquam convallis. Etiam ultricies tristique mi. Curabitur suscipit arcu id tortor. Etiam dui sapien, eleifend a, adipiscing ac, dignissim vitae, quam. Suspendisse potenti. Sed consequat metus quis nunc. Phasellus dictum nibh id ipsum. Aenean posuere dictum purus. Morbi venenatis vulputate lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed euismod. Aenean velit justo, vulputate in, molestie vel, adipiscing eu, tortor.
|
8
|
+
|
9
|
+
Vestibulum sollicitudin ante eget nunc. Donec nec lectus at purus mollis egestas. Mauris risus. Morbi vehicula felis vel nibh. Etiam laoreet laoreet eros. Pellentesque neque. Nulla vitae ipsum. Praesent scelerisque tempus enim. Sed aliquam. Aenean a quam. Phasellus in diam. Vestibulum nec arcu nec nibh pulvinar laoreet.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# AccountLogin test
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require File.dirname(__FILE__) + '/testconfig'
|
5
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
6
|
+
require 'nvx/sds/accountlogin'
|
7
|
+
|
8
|
+
class AccountLoginTest < Test::Unit::TestCase
|
9
|
+
include NVX::SDS
|
10
|
+
|
11
|
+
def test_Login
|
12
|
+
accountLogin = AccountLogin.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
|
13
|
+
accountLogin.Login
|
14
|
+
assert accountLogin.username == "uploadtest"
|
15
|
+
assert accountLogin.app_name == "Upload Test"
|
16
|
+
assert accountLogin.session_token != nil
|
17
|
+
print "Session Token: " + accountLogin.session_token
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
# apicommand test
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
5
|
+
require 'nvx/sds/apicommand'
|
6
|
+
|
7
|
+
class APICommandTest < Test::Unit::TestCase
|
8
|
+
include NVX::SDS
|
9
|
+
|
10
|
+
#Authorization Namespace tests
|
11
|
+
def test_Login
|
12
|
+
assert APICommand.Login.command_path == "Authentication/Login.ashx"
|
13
|
+
assert APICommand.Login.is_secure?
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_Logout
|
17
|
+
assert APICommand.Logout.command_path == "Authentication/Logout.ashx"
|
18
|
+
assert !APICommand.Logout.is_secure?
|
19
|
+
end
|
20
|
+
|
21
|
+
#IMFS Namespace tests
|
22
|
+
def test_ListFolder
|
23
|
+
assert APICommand.ListFolder.command_path == "IMFS/ListFolder.ashx"
|
24
|
+
assert !APICommand.ListFolder.is_secure?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_CreateFolders
|
28
|
+
assert APICommand.CreateFolders.command_path == "IMFS/CreateFolders.ashx"
|
29
|
+
assert !APICommand.CreateFolders.is_secure?
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_DeleteFolders
|
33
|
+
assert APICommand.DeleteFolders.command_path == "IMFS/DeleteFolders.ashx"
|
34
|
+
assert !APICommand.DeleteFolders.is_secure?
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_CopyFolders
|
38
|
+
assert APICommand.CopyFolders.command_path == "IMFS/CopyFolders.ashx"
|
39
|
+
assert !APICommand.CopyFolders.is_secure?
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_MoveFolders
|
43
|
+
assert APICommand.MoveFolders.command_path == "IMFS/MoveFolders.ashx"
|
44
|
+
assert !APICommand.MoveFolders.is_secure?
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_CopyFiles
|
48
|
+
assert APICommand.CopyFiles.command_path == "IMFS/CopyFiles.ashx"
|
49
|
+
assert !APICommand.CopyFiles.is_secure?
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_MoveFiles
|
53
|
+
assert APICommand.MoveFiles.command_path == "IMFS/MoveFiles.ashx"
|
54
|
+
assert !APICommand.MoveFiles.is_secure?
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_RenameFolder
|
58
|
+
assert APICommand.RenameFolder.command_path == "IMFS/RenameFolder.ashx"
|
59
|
+
assert !APICommand.RenameFolder.is_secure?
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_RenameFile
|
63
|
+
assert APICommand.RenameFile.command_path == "IMFS/RenameFile.ashx"
|
64
|
+
assert !APICommand.RenameFile.is_secure?
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_DeleteFiles
|
68
|
+
assert APICommand.DeleteFiles.command_path == "IMFS/DeleteFiles.ashx"
|
69
|
+
assert !APICommand.DeleteFiles.is_secure?
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_GetDownloadNodes
|
73
|
+
assert APICommand.GetDownloadNodes.command_path == "IMFS/GetDownloadNodes.ashx"
|
74
|
+
assert !APICommand.GetDownloadNodes.is_secure?
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_GetUploadNode
|
78
|
+
assert APICommand.GetUploadNode.command_path == "IMFS/GetUploadNode.ashx"
|
79
|
+
assert !APICommand.GetUploadNode.is_secure?
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# MetaData Namespace
|
84
|
+
def test_DeleteAllMetadata
|
85
|
+
assert APICommand.DeleteAllMetadata.command_path == "Metadata/DeleteAllMetadata.ashx"
|
86
|
+
assert !APICommand.DeleteAllMetadata.is_secure?
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_DeleteAllTags
|
90
|
+
assert APICommand.DeleteAllTags.command_path == "Metadata/DeleteAllTags.ashx"
|
91
|
+
assert !APICommand.DeleteAllTags.is_secure?
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_DeleteMetadata
|
95
|
+
assert APICommand.DeleteMetadata.command_path == "Metadata/DeleteMetadata.ashx"
|
96
|
+
assert !APICommand.DeleteMetadata.is_secure?
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_DeleteTags
|
100
|
+
assert APICommand.DeleteTags.command_path == "Metadata/DeleteTags.ashx"
|
101
|
+
assert !APICommand.DeleteTags.is_secure?
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_GetMetadata
|
105
|
+
assert APICommand.GetMetadata.command_path == "Metadata/GetMetadata.ashx"
|
106
|
+
assert !APICommand.GetMetadata.is_secure?
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_GetTags
|
110
|
+
assert APICommand.GetTags.command_path == "Metadata/GetTags.ashx"
|
111
|
+
assert !APICommand.GetTags.is_secure?
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_SetMetadata
|
115
|
+
assert APICommand.SetMetadata.command_path == "Metadata/SetMetadata.ashx"
|
116
|
+
assert !APICommand.SetMetadata.is_secure?
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_SetTags
|
120
|
+
assert APICommand.SetTags.command_path == "Metadata/SetTags.ashx"
|
121
|
+
assert !APICommand.SetTags.is_secure?
|
122
|
+
end
|
123
|
+
|
124
|
+
# Sharing Namespace
|
125
|
+
def test_CreateHostedItem
|
126
|
+
assert APICommand.CreateHostedItem.command_path == "Sharing/CreateHostedItem.ashx"
|
127
|
+
assert !APICommand.CreateHostedItem.is_secure?
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_RemoveHostedItem
|
131
|
+
assert APICommand.RemoveHostedItem.command_path == "Sharing/RemoveHostedItem.ashx"
|
132
|
+
assert !APICommand.RemoveHostedItem.is_secure?
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_ListHostedItems
|
136
|
+
assert APICommand.ListHostedItems.command_path == "Sharing/ListHostedItems.ashx"
|
137
|
+
assert !APICommand.ListHostedItems.is_secure?
|
138
|
+
end
|
139
|
+
|
140
|
+
# Accounting Namespace
|
141
|
+
def test_CreateChildAccount
|
142
|
+
assert APICommand.CreateChildAccount.command_path == "Accounting/CreateChildAccount.ashx"
|
143
|
+
assert !APICommand.CreateChildAccount.is_secure?
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_DeleteChildAccount
|
147
|
+
assert APICommand.DeleteChildAccount.command_path == "Accounting/DeleteChildAccount.ashx"
|
148
|
+
assert !APICommand.DeleteChildAccount.is_secure?
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_GetAccountInfo
|
152
|
+
assert APICommand.GetAccountInfo.command_path == "Accounting/GetAccountInfo.ashx"
|
153
|
+
assert !APICommand.GetAccountInfo.is_secure?
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_GetAccountNotes
|
157
|
+
assert APICommand.GetAccountNotes.command_path == "Accounting/GetAccountNotes.ashx"
|
158
|
+
assert !APICommand.GetAccountNotes.is_secure?
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_GetAccountLimits
|
162
|
+
assert APICommand.GetAccountLimits.command_path == "Accounting/GetAccountLimits.ashx"
|
163
|
+
assert !APICommand.GetAccountLimits.is_secure?
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_GetAccountUsage
|
167
|
+
assert APICommand.GetAccountUsage.command_path == "Accounting/GetAccountUsage.ashx"
|
168
|
+
assert !APICommand.GetAccountUsage.is_secure?
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_SetAccountInfo
|
172
|
+
assert APICommand.SetAccountInfo.command_path == "Accounting/SetAccountInfo.ashx"
|
173
|
+
assert !APICommand.SetAccountInfo.is_secure?
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_SetAccountLimits
|
177
|
+
assert APICommand.SetAccountLimits.command_path == "Accounting/SetAccountLimits.ashx"
|
178
|
+
assert !APICommand.SetAccountLimits.is_secure?
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_SetAccountNotes
|
182
|
+
assert APICommand.SetAccountNotes.command_path == "Accounting/SetAccountNotes.ashx"
|
183
|
+
assert !APICommand.SetAccountNotes.is_secure?
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# command test
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
5
|
+
require 'nvx/sds/apiparam'
|
6
|
+
|
7
|
+
class APIParamTest < Test::Unit::TestCase
|
8
|
+
include NVX::SDS
|
9
|
+
|
10
|
+
def test_key
|
11
|
+
assert APIParam.new("key", "value").key == "key"
|
12
|
+
assert APIParam.new("key", "value").key != "notkey"
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_value
|
16
|
+
assert APIParam.new("key", "value").value == "value"
|
17
|
+
assert APIParam.new("key", "value").value != "notvalue"
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_to_s
|
21
|
+
assert APIParam.new("key", "value").to_s == "key=value"
|
22
|
+
assert APIParam.new("key", "?value").to_s == "key=%3Fvalue"
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# countries test
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
$:.unshift File.dirname(__FILE__) + '/../lib/nvx/sds/'
|
5
|
+
require 'countries'
|
6
|
+
|
7
|
+
class CountriesTest < Test::Unit::TestCase
|
8
|
+
include NVX::SDS
|
9
|
+
|
10
|
+
def test_Countries
|
11
|
+
# display all of the countries
|
12
|
+
Countries.country_list.each do |country|
|
13
|
+
print country.to_s + "\r\n"
|
14
|
+
end
|
15
|
+
# verify one entry is the correct index
|
16
|
+
assert Countries.country_list["United States"] == 1
|
17
|
+
# verify the count
|
18
|
+
assert Countries.country_list.size == 244
|
19
|
+
end
|
20
|
+
end
|
data/tests/foldertest.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# folder test
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
5
|
+
require 'nvx/sds/folder'
|
6
|
+
require 'nvx/sds/session'
|
7
|
+
require 'REXML/Document'
|
8
|
+
include REXML
|
9
|
+
require File.dirname(__FILE__) + '/testconfig'
|
10
|
+
|
11
|
+
class FolderTest < Test::Unit::TestCase
|
12
|
+
include NVX::SDS
|
13
|
+
|
14
|
+
Newline = "\r\n"
|
15
|
+
|
16
|
+
def test_Folder
|
17
|
+
|
18
|
+
session = Session.new(APP_KEY, USERNAME, APP_NAME, PASSWORD)
|
19
|
+
#page_number, page_size, folder_sort_code, should_sort_descending)
|
20
|
+
root_folder = session.GetRootFolder(1, 500, "Name", true)
|
21
|
+
print "total_folder_count" + root_folder.total_folder_count.to_s
|
22
|
+
assert root_folder.total_folder_count == 5
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|