Skip to content
This repository
Browse code

Allow token to be passed via the url parameter

  • Loading branch information...
commit 63f128fae1461688ffcd581237cfef8d4fc71874 1 parent 9b59e8b
James Allen authored August 11, 2011
3  app/controllers/clsi_controller.rb
@@ -35,6 +35,9 @@ def compile
35 35
       }
36 36
     end
37 37
 
  38
+    if params[:token] and params[:token].is_a?(String)
  39
+      @request_attributes[:token] = params[:token]
  40
+    end
38 41
     @compile = Compile.new(@request_attributes)
39 42
     @compile.unique_id
40 43
     if @request_attributes[:asynchronous]
2  app/models/json_parser.rb
@@ -21,8 +21,6 @@ def self.parse_request(json_request)
21 21
     if compile.has_key?("token")
22 22
       raise CLSI::ParseError, "token attribute should be a string" unless compile["token"].is_a?(String)
23 23
       request[:token] = compile["token"]
24  
-    else
25  
-      raise CLSI::ParseError, "no token attribute found"
26 24
     end
27 25
     
28 26
     options = compile["options"] || {}
5  app/models/xml_parser.rb
@@ -14,8 +14,9 @@ def self.parse_request(xml_request)
14 14
     raise CLSI::ParseError, 'no <compile> ... </> tag found' if compile_tag.nil?
15 15
 
16 16
     token_tag = compile_tag.elements['token']
17  
-    raise CLSI::ParseError, 'no <token> ... </> tag found' if token_tag.nil?
18  
-    request[:token] = token_tag.text
  17
+    unless token_tag.nil?
  18
+      request[:token] = token_tag.text
  19
+    end
19 20
 
20 21
     options_tag = compile_tag.elements['options']
21 22
     unless options_tag.nil?
11  spec/models/json_parser_spec.rb
@@ -26,17 +26,6 @@
26 26
       }.should raise_error(CLSI::ParseError, 'compile attribute should be a hash')
27 27
     end
28 28
     
29  
-    it "should raise a CLSI::ParseError if there is no token attribute" do  
30  
-      lambda{
31  
-        JSONParser.parse_request(<<-EOS
32  
-          {
33  
-            "compile" : {}
34  
-          }
35  
-        EOS
36  
-        )
37  
-      }.should raise_error(CLSI::ParseError, 'no token attribute found')
38  
-    end
39  
-    
40 29
     it "should raise a CLSI::ParseError if the token attribute is not a string" do  
41 30
       lambda{
42 31
         JSONParser.parse_request(<<-EOS
6  spec/models/xml_parser_spec.rb
@@ -15,12 +15,6 @@
15 15
       }.should raise_error(CLSI::ParseError, 'no <compile> ... </> tag found')      
16 16
     end
17 17
 
18  
-    it "should raise a CLSI::ParseError if there is no token tag" do
19  
-      lambda{
20  
-        XMLParser.parse_request('<compile></compile>')
21  
-      }.should raise_error(CLSI::ParseError, 'no <token> ... </> tag found')      
22  
-    end
23  
-
24 18
     it "should raise a CLSI::ParseError if there is no resources tag" do
25 19
       lambda{
26 20
         XMLParser.parse_request(<<-EOS

0 notes on commit 63f128f

Please sign in to comment.
Something went wrong with that request. Please try again.