Sha256: 938f8a0fe194e63f3cc865bf07e76be46c0b31c8274b927bd1b10cc6b91cb3c4

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

require 'net/http'
require 'webrick/httpproxy'

describe "web proxy" do
  if false
  it "shoudld refer to a global_web_server through a global_application_interface" do
    b=TestBed.new
b.run("UdpNetwork")
    b.run("DirectoryService")
    ns=b.run("NameService")
    sleep 2
    
    ns.export("test.appswarm","myInstance")
    
    b.run("GlobalWebServer")
    b.run("GlobalApplicationInterface")
    proxy=b.run("GlobalWebProxy")
    
    proxy["test.appswarm"].get("CHECK").should == "RETURN [CHECK]"
    
    b.stop
  end
end
  
  it "should be possible to access redmine on 127.0.0.1 3000" do
    Net::HTTP.start("127.0.0.1",3000){|http|
      pp http.get("/")
    }
    1.should == 1
  end
  
  it "should be possible to access redmine across a proxy" do
    proxy_port=9999
    proxy_addr="127.0.0.1"
    proxy=WEBrick::HTTPProxyServer.new(:BindAddress=>proxy_addr,:Port=>proxy_port)
    t2=Thread.new {proxy.start}
    Net::HTTP::Proxy(proxy_addr, proxy_port).start('127.0.0.1','3000') {|http|
      puts "HTTP OPENED"
      #t=Thread.new {
      begin
      result=http.get("/")
      rescue Object=>e
        pp e,e.backtrace
      end
      #}
      #sleep 5
      #t.raise Exception.new
      puts "GETTTT"
      pp result
      proxy.shutdown
    }
  end
  
  
  it "should work on a proxy-connection" do
    b=TestBed.new

b.run("UdpNetwork")
    b.run("DirectoryService")
    ns=b.run("NameService")
    sleep 2
    
    ns.export("test.appswarm","myInstance")
    
    b.run("GlobalWebServer")
    b.run("GlobalApplicationInterface")
    proxy=b.run("GlobalWebProxy")
  
    sleep 2
     proxy_addr = '127.0.0.1'
     proxy_port = proxy.port

     puts "TRYING PROXY #{proxy_addr} #{proxy_port}"
     Net::HTTP::Proxy(proxy_addr, proxy_port).start('test.appswarm') {|http|
       puts "HTTP OPENED"
       result=nil
       begin
       result=http.get("/?arg1=p1")
       rescue Object=>e
         pp e,e.backtrace
       end
       pp "PROXY_RESULT:",result
       pp result.body
     }
     b.stop

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appswarm-0.0.1 apps/global_web_proxy/spec/web_proxy_spec.rb