rally_api 0.9.16 → 0.9.17.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
- require "httpclient"
1
+ require 'httpclient'
2
2
  require 'json'
3
+ require 'nokogiri'
3
4
 
4
5
  # :stopdoc:
5
6
  #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
@@ -67,6 +68,63 @@ module RallyAPI
67
68
  @security_token = keyval
68
69
  end
69
70
 
71
+ #==========================================================================================================
72
+ #new sso auth method - experimental
73
+ def do_sso_auth(rally_sso_url, sso_user, sso_password)
74
+ step1res = @rally_http_client.request(:get, rally_sso_url, {:follow_redirect => true})
75
+ step1action = get_sso_form_info(step1res)
76
+
77
+ post_content2 = {:body => step1action[:inputs], :follow_redirect => true}
78
+ step2res = @rally_http_client.post(step1action[:action_url], post_content2)
79
+ step2action = get_sso_form_info(step2res)
80
+ step2formdata = {}
81
+ step2action[:inputs].each_key do |nm|
82
+ if nm.downcase.include?("name")
83
+ step2formdata[nm] = sso_user
84
+ elsif nm.downcase.include?("pass")
85
+ step2formdata[nm] = sso_password
86
+ end
87
+ end
88
+
89
+ base_url = URI.parse(step1action[:action_url])
90
+
91
+ step3_url = "#{base_url.scheme}://#{base_url.host}#{step2action[:action_url]}"
92
+ post_content3 = {:body => step2formdata, :follow_redirect => true}
93
+ step3res = @rally_http_client.post(step3_url, post_content3)
94
+ step3action = get_sso_form_info(step3res)
95
+ post_content4 = {:body => step3action[:inputs], :follow_redirect => true}
96
+
97
+ #step4_url = "#{base_url.scheme}://#{base_url.host}#{step3action[:action_url]}"
98
+ step4res = @rally_http_client.post(step3action[:action_url], post_content4)
99
+ log_info("got step4 #{step4res.body}")
100
+
101
+ step4action = get_sso_form_info(step4res)
102
+ post_content5 = {:body => step4action[:inputs], :follow_redirect => true}
103
+ step5res = @rally_http_client.post(step4action[:action_url], post_content5)
104
+ log_info("got step5 #{step5res.body}")
105
+
106
+ res = @rally_http_client.get("https://rally1.rallydev.com/slm/webservice/1.42/user.js")
107
+ log_info("final result: #{res.body}")
108
+ true
109
+ end
110
+
111
+ def get_sso_form_info(form_html)
112
+ log_info ("===================\nparsing #{form_html.body}\n======================")
113
+ parsed_html = Nokogiri::HTML(form_html.body)
114
+ inputs = {}
115
+ parsed_html.css("//input").each do |inp|
116
+ next if inp["name"].nil?
117
+ inputs[inp["name"]] = inp["value"]
118
+ end
119
+
120
+ form = parsed_html.at("//form")
121
+ form_action = form["action"]
122
+ return_val = {:action_url => form_action, :inputs => inputs}
123
+ log_info("\n==========================\n#{return_val}\n============================\n")
124
+ return_val
125
+ end
126
+ #==========================================================================================================
127
+
70
128
  def logger=(log_dev)
71
129
  @logger = log_dev
72
130
  @rally_http_client.debug_dev = log_dev
@@ -48,13 +48,14 @@ module RallyAPI
48
48
 
49
49
  attr_accessor :rally_url, :rally_user, :rally_password, :rally_workspace_name, :rally_project_name, :wsapi_version,
50
50
  :rally_headers, :rally_default_workspace, :rally_default_project, :low_debug, :proxy_info,
51
- :rally_rest_api_compat, :logger, :rally_alias_types
51
+ :rally_rest_api_compat, :logger, :rally_alias_types, :rally_sso_url
52
52
  attr_reader :rally_connection
53
53
 
54
54
  def initialize(args)
55
55
  @rally_alias_types = { "story" => "HierarchicalRequirement", "userstory" => "HierarchicalRequirement" }
56
56
 
57
57
  @rally_url = args[:base_url] || "https://rally1.rallydev.com/slm"
58
+ @rally_sso_url = args[:rally_sso_url]
58
59
  @rally_user = args[:username]
59
60
  @rally_password = args[:password]
60
61
  @rally_workspace_name = args[:workspace]
@@ -63,20 +64,12 @@ module RallyAPI
63
64
  @rally_headers = args[:headers] || CustomHttpHeader.new
64
65
  @proxy_info = args[:proxy]
65
66
  @skip_sec_key = args[:skip_sec_key]
66
-
67
67
  #flag to help RallyRestAPI users to use snake case field names eg Defect.fixed_in_build vs Defect["FixedInBuild"]
68
- @rally_rest_api_compat = args[:rally_rest_api_compat] || false
68
+ @rally_rest_api_compat = args[:rally_rest_api_compat] || false
69
+ @low_debug = args[:debug] || false
70
+ @logger = args[:logger] || nil #assumes this is an instance of Logger
69
71
 
70
- @low_debug = args[:debug] || false
71
- @logger = args[:logger] || nil #assumes this is an instance of Logger
72
-
73
- @rally_connection = RallyJsonConnection.new(@rally_headers, @low_debug, @proxy_info)
74
- @rally_connection.set_client_user(@rally_url, @rally_user, @rally_password)
75
- @rally_connection.logger = @logger unless @logger.nil?
76
-
77
- if @wsapi_version.to_s.include?("v2.") && !@skip_sec_key
78
- @rally_connection.setup_security_token(security_url)
79
- end
72
+ setup_rally_connection
80
73
 
81
74
  if !@rally_workspace_name.nil?
82
75
  @rally_default_workspace = find_workspace(@rally_workspace_name)
@@ -91,6 +84,20 @@ module RallyAPI
91
84
  self
92
85
  end
93
86
 
87
+ def setup_rally_connection
88
+ @rally_connection = RallyJsonConnection.new(@rally_headers, @low_debug, @proxy_info)
89
+ @rally_connection.logger = @logger unless @logger.nil?
90
+ if @rally_sso_url.nil?
91
+ @rally_connection.set_client_user(@rally_url, @rally_user, @rally_password)
92
+ else
93
+ @rally_connection.do_sso_auth(@rally_sso_url, @rally_user, @rally_password)
94
+ end
95
+
96
+ if @wsapi_version.to_s.include?("v2.") && !@skip_sec_key
97
+ @rally_connection.setup_security_token(security_url)
98
+ end
99
+ end
100
+
94
101
  def debug_logging_on
95
102
  @low_debug = true
96
103
  @rally_connection.low_debug = true
@@ -4,5 +4,5 @@
4
4
  #of the applicable Subscription Agreement between your company and
5
5
  #Rally Software Development Corp.
6
6
  module RallyAPI
7
- VERSION = "0.9.16"
7
+ VERSION = "0.9.17.pre"
8
8
  end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rally_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.16
5
- prerelease:
4
+ version: 0.9.17.pre
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dave Smith
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-12 00:00:00.000000000Z
12
+ date: 2013-06-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
16
- requirement: &70253691004580 !ruby/object:Gem::Requirement
16
+ requirement: &70356434093580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,21 @@ dependencies:
21
21
  version: 2.3.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70253691004580
24
+ version_requirements: *70356434093580
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ requirement: &70356434093080 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70356434093080
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: simplecov
27
- requirement: &70253691004160 !ruby/object:Gem::Requirement
38
+ requirement: &70356434092700 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
@@ -32,10 +43,10 @@ dependencies:
32
43
  version: '0'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *70253691004160
46
+ version_requirements: *70356434092700
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rspec
38
- requirement: &70253691003700 !ruby/object:Gem::Requirement
49
+ requirement: &70356434092220 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *70253691003700
57
+ version_requirements: *70356434092220
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rake
49
- requirement: &70253691003280 !ruby/object:Gem::Requirement
60
+ requirement: &70356434091800 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,7 +65,7 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *70253691003280
68
+ version_requirements: *70356434091800
58
69
  description: API wrapper for Rally's JSON REST web services api
59
70
  email:
60
71
  - dsmith@rallydev.com
@@ -89,9 +100,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
100
  required_rubygems_version: !ruby/object:Gem::Requirement
90
101
  none: false
91
102
  requirements:
92
- - - ! '>='
103
+ - - ! '>'
93
104
  - !ruby/object:Gem::Version
94
- version: '0'
105
+ version: 1.3.1
95
106
  requirements: []
96
107
  rubyforge_project: rally_api
97
108
  rubygems_version: 1.8.6