Created
May 18, 2012 11:12
-
-
Save jbpros/2724720 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class World | |
| # ... | |
| commandRemote: (commandName, data, callback) -> | |
| postData = querystring.stringify payload | |
| options = | |
| host: @host, | |
| port: @port, | |
| path: "#{@path}/#{commandName}", | |
| method: 'PUT' | |
| headers: | |
| 'Content-Type': 'application/x-www-form-urlencoded', | |
| 'Content-Length': postData.length | |
| req = http.request options, (res) => | |
| throw new Error('Failed to execute remote command') if res.statusCode == 500 | |
| responseData = "" | |
| res.on 'data', (data) -> | |
| responseData += data | |
| res.on 'end', -> | |
| result = JSON.parse responseData | |
| callback result | |
| req.end postData |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'database_cleaner' | |
| DatabaseCleaner.strategy = :truncation | |
| class BackdoorsController < ApplicationController | |
| skip_before_filter :verify_authenticity_token | |
| def get_user_attributes_from_id | |
| user = User.find params[:user_id] | |
| render :json => user.attributes.to_json | |
| end | |
| def reset_all | |
| DatabaseCleaner.clean | |
| render :json => nil | |
| end | |
| def stub_provider_response | |
| provider = params[:provider] | |
| response = JSON.parse params[:response] | |
| OmniAuth.config.add_mock :twitter, response | |
| render :json => nil | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| YourApp::Application.routes.draw do | |
| # ... | |
| if Rails.env == 'cucumber' | |
| match '/__backdoors__/:action', :controller => 'backdoors' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment