From 7f31b4e14f4e4d0dad4e9e35b7b351f3606a6319 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 20 Oct 2016 03:21:17 +0200 Subject: [PATCH 1/3] Fix: If ticket/1 is inaccessible, roust would throw in authenticaed --- lib/roust.rb | 3 ++- lib/roust/ticket.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/roust.rb b/lib/roust.rb index 67d30b8..5e9aa81 100644 --- a/lib/roust.rb +++ b/lib/roust.rb @@ -60,7 +60,8 @@ def authenticate! end def authenticated? - return true if show('1') + show('1') + return true rescue Unauthenticated return false end diff --git a/lib/roust/ticket.rb b/lib/roust/ticket.rb index 0bc0a56..c3cf49a 100644 --- a/lib/roust/ticket.rb +++ b/lib/roust/ticket.rb @@ -6,6 +6,7 @@ def ticket_show(id) body, _ = explode_response(response) return nil if body =~ /^# (Ticket (\d+) does not exist\.)/ + return nil if body =~ /^# You are not allowed to display ticket (\d+)./ parse_ticket_attributes(body) end From c96ea1d67a8141d0090413b280007cc47c70e985 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 7 Nov 2017 01:33:35 +0100 Subject: [PATCH 2/3] Cookies are now set differently in HTTParty, RT4.4+ requires referer --- lib/roust.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/roust.rb b/lib/roust.rb index 5e9aa81..42ab058 100644 --- a/lib/roust.rb +++ b/lib/roust.rb @@ -44,7 +44,8 @@ def authenticate! ) cookie = response.headers['set-cookie'] - self.class.headers['Cookie'] = cookie if cookie + self.class.default_cookies.add_cookies(cookie) if cookie + self.class.headers(:referer => "#{@server}/REST/1.0") # Switch the base uri over to the actual REST API base uri. self.class.base_uri "#{@server}/REST/1.0" From 3cf3c48c4ede34674a3ccc8a174df3921b74dbe9 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 7 Nov 2017 01:56:28 +0100 Subject: [PATCH 3/3] Make referer symbol a string --- lib/roust.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/roust.rb b/lib/roust.rb index 42ab058..16e7026 100644 --- a/lib/roust.rb +++ b/lib/roust.rb @@ -45,7 +45,7 @@ def authenticate! cookie = response.headers['set-cookie'] self.class.default_cookies.add_cookies(cookie) if cookie - self.class.headers(:referer => "#{@server}/REST/1.0") + self.class.headers('Referer' => "#{@server}/REST/1.0") # Switch the base uri over to the actual REST API base uri. self.class.base_uri "#{@server}/REST/1.0"