Src C0 Coverage Information - RCov

lib/application_helper.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/application_helper.rb 68 45
72.06%
57.78%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 #
2 #   Copyright [2011] [Red Hat, Inc.]
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #   http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #  limitations under the License.
15 #
16 require 'oauth'
17 require 'oauth/request_proxy/rack_request'
18 require 'lib/model/consumer'
19 
20 module ApplicationHelper
21   def logger
22     $LOGGER
23   end
24 
25   def configs
26     ConfigServer::Model.instance_config_schema_location =
27       settings.instance_config_rng
28 
29     @configs ||= ConfigServer::InstanceConfigs.new(settings)
30   end
31 
32   def app_version
33     settings.version
34   end
35 
36   def api_version
37     "1"
38   end
39 
40   def api_version_valid?(request, version)
41     root_path = request.path[0, (request.path.index('/', 1) + 1)]
42     if ["/params/", "/configs/", "/files/"].include? root_path
43       return api_version == version.to_s
44     end
45     return true
46   end
47 
48   def authenticate!
49     if not authenticated?
50       logger.debug("  **AUTHENTICATING** NOT AUTHENTICATED! (returning 401)")
51       throw :halt, [401, "Not Authorized\n"]
52     end
53   end
54 
55   def authenticated?
56     unsigned_parameters = settings.oauth_ignore_post_body ? ["data", "audrey_data"] : []
57     OAuth::Signature.verify(request, :unsigned_parameters => unsigned_parameters) do |request_proxy|
58       logger.debug("**AUTHENTICATING** key = #{request_proxy.consumer_key}")
59       consumer = ConfigServer::Model::Consumer.find(request_proxy.consumer_key)
60       if not consumer.nil?
61         [nil, consumer.secret]
62       else
63         logger.debug("  **AUTHENTICATING** No consumer secret found")
64         [nil, ""]
65       end
66     end
67   end
68 end

Generated on Wed Dec 14 16:00:31 -0500 2011 with rcov 0.9.11