versionone_sdk 0.1.2 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile +1 -1
- data/README.md +27 -3
- data/Rakefile +4 -4
- data/lib/versionone_sdk/client.rb +76 -72
- data/lib/versionone_sdk/parser_xml_assets.rb +6 -6
- data/lib/versionone_sdk/update.rb +11 -13
- data/lib/versionone_sdk/version.rb +1 -1
- data/test/test_base.rb +5 -0
- data/test/test_setup.rb +21 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35eb4c49dfa7e75b424bf730097f077bbe9a420c
|
4
|
+
data.tar.gz: e3f477f0f83e0b3fb3aa885c7c2dabcc67c8b405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e6162a198d02b40475e198fb22a4a8b864040d34b9c3389b3ed1def2d5379c7ba5198608635c8ddd66f6c78b62e6b106fe95bd6e6cc0cde5ea91540ebd72fd9
|
7
|
+
data.tar.gz: bc8d46678499d305630526f921cf9084a4cc05d88ccbaa8b5949811a356e4d391f5fd8257965575e00932c8df05c2294af386bad53bdf3650fa7b4ae115d03c5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
|
+
- **2015-02-16**: 0.2.0
|
4
|
+
- Add Access Token Authentication handling from pccasto. More info at: https://community.versionone.com/Developers/Developer-Library/Documentation/API_Authentication/Access_Token_Authentication
|
5
|
+
- Update client's default protocol, hostname and port to use constants.
|
6
|
+
- Fix Coveralls code coverage support.
|
7
|
+
- **2016-02-05**: 0.1.2
|
8
|
+
- Update `VersiononeSdk::Asset` to update call to `JsonDoc::Document`
|
3
9
|
- **2015-09-14**: 0.1.1
|
4
10
|
- Update `README.md`
|
5
11
|
- Add Travis CI, Code Climate, Coveralls support
|
@@ -14,4 +20,4 @@ CHANGELOG
|
|
14
20
|
- **2014-03-17**: 0.0.2
|
15
21
|
- Add `VersiononeSdk::Asset` object to support value inflation, starting with `AssetState.Name`
|
16
22
|
- **2014-03-16**: 0.0.1
|
17
|
-
- Initial release
|
23
|
+
- Initial release
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -23,6 +23,8 @@ It currently offers the following capabilities:
|
|
23
23
|
2. Ability to query Assets transparently using Asset OID Tokens (e.g. `Story:1`) or Asset Numbers (e.g. `B-1`).
|
24
24
|
3. Ability to update Assets using Ruby without needing to manually create XML.
|
25
25
|
|
26
|
+
Note: This SDK doesn't currently support NTLM authentication used with on-premise VersionOne deployments. An approach for this is to use [`httpclient`](https://rubygems.org/gems/httpclient) and [`rubyntlm`](https://rubygems.org/gems/rubyntlm).
|
27
|
+
|
26
28
|
## Installation
|
27
29
|
|
28
30
|
### Via Bundler
|
@@ -47,6 +49,7 @@ This gem uses `nokogiri` which requires Ruby >= 1.9.2.
|
|
47
49
|
```ruby
|
48
50
|
require 'versionone_sdk'
|
49
51
|
|
52
|
+
# Authorizing using Basic Authentication
|
50
53
|
params = {
|
51
54
|
hostname: 'www1.v1host.com',
|
52
55
|
instance: 'myinstance',
|
@@ -55,9 +58,18 @@ params = {
|
|
55
58
|
port: 443,
|
56
59
|
protocol: 'https'
|
57
60
|
}
|
61
|
+
v1client = VersiononeSdk::Client.new params
|
62
|
+
|
63
|
+
# Authorizing using Access Token Authentication
|
64
|
+
params = {
|
65
|
+
hostname: 'www1.v1host.com',
|
66
|
+
instance: 'myinstance',
|
67
|
+
access_token: 'myaccesstoken',
|
68
|
+
port: 443,
|
69
|
+
protocol: 'https'
|
70
|
+
}
|
71
|
+
v1client = VersiononeSdk::Client.new params
|
58
72
|
|
59
|
-
v1client = VersiononeSdk::Client.new(params)
|
60
|
-
|
61
73
|
# Retrieve an array of VersiononeSdk::Asset objects
|
62
74
|
assets = v1client.getAssets('Scope')
|
63
75
|
|
@@ -129,12 +141,24 @@ Project Repo
|
|
129
141
|
|
130
142
|
VersionOne API Documentation
|
131
143
|
|
132
|
-
* http://community.versionone.com/Developers/Developer-Library/Documentation
|
144
|
+
* http://community.versionone.com/Developers/Developer-Library/Documentation
|
133
145
|
|
134
146
|
VersionOne API Documentation for Updating an Asset
|
135
147
|
|
136
148
|
* https://community.versionone.com/Developers/Developer-Library/Recipes/Update_an_Asset
|
137
149
|
|
150
|
+
VersionOne Developer Google Group
|
151
|
+
|
152
|
+
* https://groups.google.com/forum/#!forum/versionone-dev
|
153
|
+
|
154
|
+
## Contributing
|
155
|
+
|
156
|
+
1. Fork it ( http://github.com/grokify/versionone-sdk-ruby/fork )
|
157
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
158
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
159
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
160
|
+
5. Create new Pull Request
|
161
|
+
|
138
162
|
## Copyright and License
|
139
163
|
|
140
164
|
VersiononeSdk © 2014-2016 by [John Wang](mailto:johncwang@gmail.com).
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rake'
|
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
4
|
desc 'Default: run unit tests.'
|
5
|
-
task :
|
5
|
+
task default: :test
|
6
6
|
|
7
7
|
desc 'Test the library.'
|
8
8
|
Rake::TestTask.new do |t|
|
@@ -14,6 +14,6 @@ end
|
|
14
14
|
desc 'Generate YARD documentation.'
|
15
15
|
task :gendoc do
|
16
16
|
#puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
|
17
|
-
system
|
18
|
-
system
|
19
|
-
end
|
17
|
+
system 'yardoc'
|
18
|
+
system 'yard stats --list-undoc'
|
19
|
+
end
|
@@ -4,124 +4,128 @@ require 'versionone_sdk/parser_xml_assets'
|
|
4
4
|
|
5
5
|
module VersiononeSdk
|
6
6
|
class Client
|
7
|
+
DEFAULT_PROTOCOL = 'https'
|
8
|
+
DEFAULT_HOSTNAME = 'localhost'
|
9
|
+
DEFAULT_PORT = 443
|
10
|
+
|
7
11
|
attr_accessor :oFaraday
|
8
12
|
attr_accessor :sInstance
|
9
13
|
|
10
|
-
def initialize(
|
11
|
-
|
12
|
-
@
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@sUrl = buildUrl(@sProtocol,@sHostname,@iPort)
|
14
|
+
def initialize(opts = {})
|
15
|
+
@sProtocol = opts[:protocol] || DEFAULT_PROTOCOL
|
16
|
+
@sHostname = opts[:hostname] || DEFAULT_HOSTNAME
|
17
|
+
@iPort = opts.key?(:port) && opts[:port] \
|
18
|
+
? opts[:port].to_i : DEFAULT_PORT
|
19
|
+
sUsername = opts[:username] || ''
|
20
|
+
sPassword = opts[:password] || ''
|
21
|
+
# VersionOne provides a mechanism for generating an access token
|
22
|
+
sAccessToken = opts[:access_token] || ''
|
23
|
+
@sInstance = opts[:instance] || ''
|
24
|
+
@dTypePrefix = {'B' => 'Story', 'E' => 'Epic'}
|
25
|
+
@sUrl = buildUrl(@sProtocol, @sHostname, @iPort)
|
23
26
|
@oFaraday = Faraday::Connection.new url: @sUrl
|
24
|
-
@oFaraday.
|
25
|
-
|
27
|
+
@oFaraday.ssl.verify = opts[:ssl_verify].to_s.match(/false/i) \
|
28
|
+
? false : true
|
29
|
+
if sAccessToken.empty?
|
30
|
+
@oFaraday.basic_auth(sUsername, sPassword)
|
31
|
+
else
|
32
|
+
# could also patch Faraday to have a method similar to basic_auth
|
33
|
+
@oFaraday.headers['Authorization'] = "Bearer #{sAccessToken}"
|
34
|
+
end
|
35
|
+
@oUpdate = VersiononeSdk::Update.new self
|
26
36
|
end
|
27
37
|
|
28
|
-
def getAsset(xAssetId1
|
29
|
-
|
30
|
-
xAssetId1.strip!
|
31
|
-
|
32
|
-
if xAssetId1 =~ /^([^:]+):([0-9]+)$/
|
33
|
-
sAssetType = $1
|
34
|
-
sAssetOid = $2.to_i
|
35
|
-
return self.getAssetForTypeAndOid( sAssetType, sAssetOid )
|
36
|
-
|
37
|
-
elsif xAssetId1 =~ /^([a-zA-Z])-[0-9]+$/
|
38
|
-
sAssetTypeAbbr = $1.upcase
|
39
|
-
sAssetType = @dTypePrefix.key?( sAssetTypeAbbr ) \
|
40
|
-
? @dTypePrefix[ sAssetTypeAbbr ] : ''
|
41
|
-
xAssetId1.upcase!
|
42
|
-
return self.getAssetForTypeAndNumber( sAssetType, xAssetId1 )
|
43
|
-
|
44
|
-
elsif !xAssetId2.nil?
|
45
|
-
if xAssetId2.is_a?(String) && xAssetId2 =~ /^[0-9]+$/
|
46
|
-
xAssetId2 = xAssetId2.to_i
|
47
|
-
end
|
38
|
+
def getAsset(xAssetId1, xAssetId2 = nil)
|
39
|
+
xAssetId1.strip!
|
48
40
|
|
49
|
-
|
41
|
+
if xAssetId1 =~ /^([^:]+):([0-9]+)$/
|
42
|
+
sAssetType = $1
|
43
|
+
sAssetOid = $2.to_i
|
44
|
+
return self.getAssetForTypeAndOid(sAssetType, sAssetOid)
|
50
45
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
sAssetNumber.upcase!
|
58
|
-
return self.getAssetForTypeAndNumber( sAssetType, sAssetNumber )
|
59
|
-
elsif xAssetId1 =~ /^[a-zA-Z].+$/
|
60
|
-
return self.getAssetForTypeAndOid( xAssetId1, xAssetId2 )
|
61
|
-
end
|
46
|
+
elsif xAssetId1 =~ /^([a-zA-Z])-[0-9]+$/
|
47
|
+
sAssetTypeAbbr = $1.upcase
|
48
|
+
sAssetType = @dTypePrefix.key?(sAssetTypeAbbr) \
|
49
|
+
? @dTypePrefix[ sAssetTypeAbbr ] : ''
|
50
|
+
xAssetId1.upcase!
|
51
|
+
return self.getAssetForTypeAndNumber(sAssetType, xAssetId1)
|
62
52
|
|
63
|
-
|
53
|
+
elsif !xAssetId2.nil?
|
54
|
+
if xAssetId2.is_a?(String) && xAssetId2 =~ /^[0-9]+$/
|
55
|
+
xAssetId2 = xAssetId2.to_i
|
56
|
+
end
|
64
57
|
|
58
|
+
if xAssetId2.is_a?(Integer)
|
59
|
+
|
60
|
+
if xAssetId1 =~ /^[a-zA-Z]$/
|
61
|
+
xAssetId1.upcase!
|
62
|
+
sAssetTypeAbbr = xAssetId1
|
63
|
+
sAssetType = @dTypePrefix.key?(sAssetTypeAbbr) \
|
64
|
+
? @dTypePrefix[ sAssetTypeAbbr ] : ''
|
65
|
+
sAssetNumber = xAssetId1 + '-' + xAssetId2.to_s
|
66
|
+
sAssetNumber.upcase!
|
67
|
+
return self.getAssetForTypeAndNumber(sAssetType, sAssetNumber)
|
68
|
+
elsif xAssetId1 =~ /^[a-zA-Z].+$/
|
69
|
+
return self.getAssetForTypeAndOid(xAssetId1, xAssetId2)
|
70
|
+
end
|
65
71
|
end
|
66
|
-
else
|
67
|
-
raise RuntimeError, 'E_NO_ASSET_ID'
|
68
72
|
end
|
73
|
+
|
69
74
|
raise RuntimeError, "E_UNKNOWN_ASSET_ID [#{xAssetId1}][#{xAssetId2.to_s}]"
|
70
75
|
end
|
71
76
|
|
72
|
-
def getAssetForTypeAndOid(sAssetType=nil,sAssetOid=nil)
|
73
|
-
sUrl
|
74
|
-
|
75
|
-
oRes = @oFaraday.get sUrl
|
77
|
+
def getAssetForTypeAndOid(sAssetType = nil, sAssetOid = nil)
|
78
|
+
sUrl = self.getUrlForAssets( sAssetType, sAssetOid )
|
79
|
+
oRes = @oFaraday.get sUrl
|
76
80
|
oParser = VersiononeSdk::ParserXmlAssets.new({:url => @sUrl})
|
77
|
-
aDoc
|
81
|
+
aDoc = oParser.getDocForAssetXml( oRes.body )
|
78
82
|
end
|
79
83
|
|
80
|
-
def getAssetForTypeAndNumber(sAssetType=nil,sAssetNumber=nil)
|
81
|
-
sUrl
|
82
|
-
oRes
|
84
|
+
def getAssetForTypeAndNumber(sAssetType = nil, sAssetNumber = nil)
|
85
|
+
sUrl = self.getUrlForAssetTypeAndNumber( sAssetType, sAssetNumber )
|
86
|
+
oRes = @oFaraday.get sUrl
|
83
87
|
oParser = VersiononeSdk::ParserXmlAssets.new({:url => @sUrl})
|
84
|
-
aDocs
|
88
|
+
aDocs = oParser.getDocsForAssetsXml( oRes.body )
|
85
89
|
return aDocs[0]
|
86
90
|
end
|
87
91
|
|
88
|
-
def getAssets(sAssetType=nil,xIds=nil)
|
89
|
-
oRes
|
92
|
+
def getAssets(sAssetType = nil, xIds = nil)
|
93
|
+
oRes = self.getAssetsXml(sAssetType,xIds)
|
90
94
|
oParser = VersiononeSdk::ParserXmlAssets.new({:url => @sUrl})
|
91
|
-
aDocs
|
95
|
+
aDocs = oParser.getDocsForAssetsXml( oRes.body )
|
92
96
|
return aDocs
|
93
97
|
end
|
94
98
|
|
95
|
-
def getAssetsXml(sAssetType=nil,xIds=nil)
|
99
|
+
def getAssetsXml(sAssetType = nil, xIds = nil)
|
96
100
|
sUrl = self.getUrlForAssets(sAssetType)
|
97
101
|
oRes = @oFaraday.get sUrl
|
98
102
|
return oRes
|
99
103
|
end
|
100
104
|
|
101
|
-
def getUrlForAssetTypeAndNumber(sAssetType=nil,sAssetNumber=nil)
|
105
|
+
def getUrlForAssetTypeAndNumber(sAssetType = nil, sAssetNumber = nil)
|
102
106
|
aUrl = [ @sUrl, @sInstance, 'rest-1.v1/Data',sAssetType + %Q!?where=Number="#{sAssetNumber}"!]
|
103
107
|
sUrl = aUrl.join('/')
|
104
108
|
return sUrl
|
105
109
|
end
|
106
110
|
|
107
|
-
def getUrlForAssets(sAssetType=nil,sAssetOid=nil)
|
108
|
-
aUrl = [
|
111
|
+
def getUrlForAssets(sAssetType = nil, sAssetOid = nil)
|
112
|
+
aUrl = [@sUrl, @sInstance, 'rest-1.v1/Data',sAssetType]
|
109
113
|
if sAssetOid.is_a?(Integer)
|
110
|
-
aUrl.push
|
114
|
+
aUrl.push sAssetOid
|
111
115
|
elsif sAssetOid.kind_of?(String) && sAssetOid =~ /^[0-9]+$/
|
112
|
-
aUrl.push
|
116
|
+
aUrl.push sAssetOid
|
113
117
|
end
|
114
118
|
sUrl = aUrl.join('/')
|
115
119
|
return sUrl
|
116
120
|
end
|
117
121
|
|
118
122
|
def updateAsset(sAssetType=nil,sAssetOid=nil,sName=nil,xxValues=nil,yTagType=nil)
|
119
|
-
return @oUpdate.updateAsset(sAssetType,sAssetOid,sName,xxValues,yTagType)
|
123
|
+
return @oUpdate.updateAsset(sAssetType, sAssetOid, sName, xxValues, yTagType)
|
120
124
|
end
|
121
125
|
|
122
126
|
private
|
123
127
|
|
124
|
-
def buildUrl(sProtocol=
|
128
|
+
def buildUrl(sProtocol = DEFAULT_PROTOCOL, sHostname = DEFAULT_HOSTNAME, iPort = DEFAULT_PORT)
|
125
129
|
if sHostname.nil?
|
126
130
|
sHostname = 'localhost'
|
127
131
|
elsif sHostname.is_a?(String)
|
@@ -139,9 +143,9 @@ module VersiononeSdk
|
|
139
143
|
elsif ! iPort.kind_of?(Integer)
|
140
144
|
raise ArgumentError, 'E_PORT_IS_NOT_AN_INTEGER'
|
141
145
|
end
|
142
|
-
sBaseUrl
|
146
|
+
sBaseUrl = "#{sProtocol}://#{sHostname}"
|
143
147
|
sBaseUrl.sub!(/\/+\s*$/,'')
|
144
|
-
sBaseUrl
|
148
|
+
sBaseUrl += ':' + iPort.to_s if iPort != 80
|
145
149
|
return sBaseUrl
|
146
150
|
end
|
147
151
|
end
|
@@ -14,9 +14,9 @@ module VersiononeSdk
|
|
14
14
|
return []
|
15
15
|
end
|
16
16
|
def getDocsForAssetsXml(xAssets=nil)
|
17
|
-
oXml
|
17
|
+
oXml = Nokogiri::XML::Document.parse(xAssets)
|
18
18
|
oBlock = oXml.xpath("//Assets/Asset")
|
19
|
-
aDocs
|
19
|
+
aDocs = []
|
20
20
|
oBlock.map do |oNodeAsset|
|
21
21
|
oAsset = self.getJsondocForXmlAssetNode( oNodeAsset )
|
22
22
|
unless oAsset.nil?
|
@@ -26,7 +26,7 @@ module VersiononeSdk
|
|
26
26
|
return aDocs
|
27
27
|
end
|
28
28
|
def getDocForAssetXml(xAsset=nil)
|
29
|
-
oXml
|
29
|
+
oXml = Nokogiri::XML::Document.parse(xAsset)
|
30
30
|
oAsset = self.getJsondocForXmlAssetNode( oXml.root )
|
31
31
|
return oAsset
|
32
32
|
end
|
@@ -58,7 +58,7 @@ module VersiononeSdk
|
|
58
58
|
oNodeAsset.children.each do |oNodeChild|
|
59
59
|
if oNodeChild.name == 'Attribute' || oNodeChild.name == 'Relation'
|
60
60
|
if oNodeChild.attribute('name')
|
61
|
-
yPropKey
|
61
|
+
yPropKey = oNodeChild.attribute('name').to_s.to_sym
|
62
62
|
xxPropVal = getAssetNodeChildPropVal( oNodeChild )
|
63
63
|
oAsset.setProp(yPropKey,xxPropVal)
|
64
64
|
end
|
@@ -90,9 +90,9 @@ module VersiononeSdk
|
|
90
90
|
xxPropVal = nil
|
91
91
|
end
|
92
92
|
else
|
93
|
-
xxPropVal
|
93
|
+
xxPropVal = oNodeChild.text
|
94
94
|
end
|
95
|
-
xxPropVal
|
95
|
+
xxPropVal = nil if xxPropVal == ''
|
96
96
|
return xxPropVal
|
97
97
|
end
|
98
98
|
end
|
@@ -3,8 +3,8 @@ require 'nokogiri'
|
|
3
3
|
module VersiononeSdk
|
4
4
|
class Update
|
5
5
|
def initialize(oClient=nil)
|
6
|
-
@oClient
|
7
|
-
@dTagTypes
|
6
|
+
@oClient = oClient
|
7
|
+
@dTagTypes = {simple_attribute: 1, single_relationship: 1, multi_relationship: 1}
|
8
8
|
@sRelationships = 'BuildProjects,Owner,Parent,Schedule,Scheme,SecurityScope,Status,TestSuite'
|
9
9
|
@dRelationships = Hash[@sRelationships.split(',').collect {|v| [v,1]}]
|
10
10
|
end
|
@@ -18,9 +18,7 @@ module VersiononeSdk
|
|
18
18
|
# +xxValues+:: values to be updated which can be a variety of formats.
|
19
19
|
# +yTagType+:: A optional symbol to identify the type of attribute, e.g.
|
20
20
|
# :simple_attribute, :single_relationship, or :multi_relationship
|
21
|
-
|
22
21
|
def updateAsset(sAssetType=nil,sAssetOid=nil,sName=nil,xxValues=nil,yTagType=nil)
|
23
|
-
|
24
22
|
aValues = normalizeValues(xxValues)
|
25
23
|
# Validate Tag Type
|
26
24
|
yTagType = yTagType.to_sym if yTagType.is_a?(String)
|
@@ -76,14 +74,14 @@ module VersiononeSdk
|
|
76
74
|
aValues = []
|
77
75
|
|
78
76
|
if xxValues.is_a?(String)
|
79
|
-
aValues = [{:
|
77
|
+
aValues = [{value: xxValues, act: 'set'}]
|
80
78
|
elsif xxValues.is_a?(Hash)
|
81
79
|
aValues = [xxValues]
|
82
80
|
elsif xxValues.is_a?(Array)
|
83
81
|
xxValues.each do |xxSubValue|
|
84
82
|
if xxSubValue.is_a?(String)
|
85
83
|
sAct = xxValues.length > 1 ? 'add' : 'set'
|
86
|
-
aValues.push({:
|
84
|
+
aValues.push({value: xxSubValue, act: sAct})
|
87
85
|
elsif xxSubValue.is_a?(Hash)
|
88
86
|
aValues.push(xxSubValue)
|
89
87
|
end
|
@@ -103,7 +101,7 @@ module VersiononeSdk
|
|
103
101
|
? aValues[0][:value] : nil
|
104
102
|
oBuilder = Nokogiri::XML::Builder.new do |xml|
|
105
103
|
xml.Asset {
|
106
|
-
xml.Attribute(sValue, :
|
104
|
+
xml.Attribute(sValue, name: sName, act: 'set')
|
107
105
|
}
|
108
106
|
end
|
109
107
|
return oBuilder.to_xml
|
@@ -114,11 +112,11 @@ module VersiononeSdk
|
|
114
112
|
? aValues[0][:value] : nil
|
115
113
|
oBuilder = sValue.nil? \
|
116
114
|
? Nokogiri::XML::Builder.new { |xml| xml.Asset { \
|
117
|
-
xml.Relation(:
|
115
|
+
xml.Relation(name: sName, act: 'set')
|
118
116
|
} }
|
119
117
|
: Nokogiri::XML::Builder.new { |xml| xml.Asset { \
|
120
|
-
xml.Relation(:
|
121
|
-
xml.Asset(:
|
118
|
+
xml.Relation(name: sName, act: 'set') {
|
119
|
+
xml.Asset(idref: sValue)
|
122
120
|
}
|
123
121
|
} }
|
124
122
|
return oBuilder.to_xml
|
@@ -127,12 +125,12 @@ module VersiononeSdk
|
|
127
125
|
def getXmlBodyForMultiRelationship(sName=nil,aValues=[])
|
128
126
|
oBuilder = aValues.length == 0 \
|
129
127
|
? Nokogiri::XML::Builder.new { |xml| xml.Asset { \
|
130
|
-
xml.Relation(:
|
128
|
+
xml.Relation(name: sName, act: 'set')
|
131
129
|
} }
|
132
130
|
: Nokogiri::XML::Builder.new { |xml| xml.Asset { \
|
133
|
-
xml.Relation(:
|
131
|
+
xml.Relation(name: sName) {
|
134
132
|
aValues.each do |dValue|
|
135
|
-
xml.Asset(:
|
133
|
+
xml.Asset(idref: dValue[:value], act: dValue[:act])
|
136
134
|
end
|
137
135
|
}
|
138
136
|
} }
|
data/test/test_base.rb
ADDED
data/test/test_setup.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
require 'test/
|
2
|
-
require 'versionone_sdk'
|
3
|
-
|
4
|
-
require 'pp'
|
1
|
+
require './test/test_base.rb'
|
5
2
|
|
6
3
|
class VersiononeSdkTest < Test::Unit::TestCase
|
7
4
|
def testSetup
|
@@ -23,4 +20,24 @@ class VersiononeSdkTest < Test::Unit::TestCase
|
|
23
20
|
|
24
21
|
assert_equal 'Closed', oAsset.getProp(:'AssetState.Name')
|
25
22
|
end
|
23
|
+
|
24
|
+
def testClient
|
25
|
+
oClient = VersiononeSdk::Client.new(instance: 'Test')
|
26
|
+
assert_equal 'https://localhost:443/Test/rest-1.v1/Data/',
|
27
|
+
oClient.getUrlForAssets
|
28
|
+
assert oClient.oFaraday.ssl.verify
|
29
|
+
|
30
|
+
oClient = VersiononeSdk::Client.new(instance: 'Test', ssl_verify: false)
|
31
|
+
assert !(oClient.oFaraday.ssl.verify)
|
32
|
+
|
33
|
+
oClient = VersiononeSdk::Client.new(protocol: 'http', user: 'user',
|
34
|
+
password: 'pass', port: 80, access_token: '', instance: 'Test')
|
35
|
+
assert_equal 'http://localhost/Test/rest-1.v1/Data/', oClient.getUrlForAssets
|
36
|
+
assert_match /\ABasic /, oClient.oFaraday.headers['Authorization']
|
37
|
+
|
38
|
+
sAccessToken = 'some_string_generated_from_version_one'
|
39
|
+
oClient = VersiononeSdk::Client.new(protocol: 'https', port: 443,
|
40
|
+
access_token: sAccessToken, instance: Test)
|
41
|
+
assert_equal "Bearer #{sAccessToken}", oClient.oFaraday.headers['Authorization']
|
42
|
+
end
|
26
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: versionone_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/versionone_sdk/parser_xml_assets.rb
|
88
88
|
- lib/versionone_sdk/update.rb
|
89
89
|
- lib/versionone_sdk/version.rb
|
90
|
+
- test/test_base.rb
|
90
91
|
- test/test_setup.rb
|
91
92
|
homepage: http://johnwang.com/
|
92
93
|
licenses:
|