dot_net_services 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/LICENSE +21 -24
  2. data/README +26 -16
  3. data/Rakefile +65 -0
  4. data/lib/acs/saml_token_provider.rb +54 -0
  5. data/lib/acs/shared_secret_token_provider.rb +55 -0
  6. data/lib/acs/simple_api_auth_token_provider.rb +57 -0
  7. data/lib/acs/simple_web_token_provider.rb +54 -0
  8. data/lib/acs/token_constants.rb +112 -0
  9. data/lib/acs/token_info.rb +33 -0
  10. data/lib/acs/token_provider.rb +74 -0
  11. data/lib/acs/token_validator.rb +114 -0
  12. data/lib/common/dot_net_services_environment.rb +61 -0
  13. data/lib/common/environment.yml +23 -0
  14. data/lib/common/host_name_config.yml +45 -0
  15. data/lib/dot_net_services.rb +31 -144
  16. data/lib/service_bus/http_proxy.rb +34 -0
  17. data/lib/service_bus/locked_message_info.rb +34 -0
  18. data/lib/service_bus/message_buffer.rb +313 -0
  19. data/lib/service_bus/message_buffer_constants.rb +48 -0
  20. data/lib/service_bus/message_buffer_policy.rb +55 -0
  21. data/lib/service_bus/requests.rb +95 -0
  22. data/test/config/test_config.yml +40 -0
  23. data/test/dot_net_services_environment_test.rb +54 -0
  24. data/test/message_buffer_test.rb +96 -0
  25. data/test/token_test.rb +98 -0
  26. metadata +50 -48
  27. data/lib/dot_net_services/authentication.rb +0 -168
  28. data/lib/dot_net_services/error.rb +0 -4
  29. data/lib/dot_net_services/message_buffer.rb +0 -283
  30. data/lib/dot_net_services/session.rb +0 -308
  31. data/lib/net/http/create_mb.rb +0 -14
  32. data/lib/net/http/retrieve.rb +0 -14
  33. data/lib/net/http/subscribe.rb +0 -14
  34. data/lib/net/http/unsubscribe.rb +0 -14
  35. data/spec/integration/TestService/Service/AnonymousResourceService.cs +0 -9
  36. data/spec/integration/TestService/Service/App.config +0 -32
  37. data/spec/integration/TestService/Service/PlainTextService.cs +0 -37
  38. data/spec/integration/TestService/Service/Program.cs +0 -49
  39. data/spec/integration/TestService/Service/Properties/AssemblyInfo.cs +0 -33
  40. data/spec/integration/TestService/Service/ResourceContract.cs +0 -17
  41. data/spec/integration/TestService/Service/ResourceService.cs +0 -58
  42. data/spec/integration/TestService/Service/Service.csproj +0 -71
  43. data/spec/integration/TestService/TestService.sln +0 -33
  44. data/spec/integration/end_to_end_spec.rb +0 -84
  45. data/spec/integration/vmb_spec.rb +0 -30
  46. data/spec/spec_helper.rb +0 -23
  47. data/spec/unit/dot_net_services/authentication_spec.rb +0 -289
  48. data/spec/unit/dot_net_services/message_buffer_spec.rb +0 -161
  49. data/spec/unit/dot_net_services/session_spec.rb +0 -247
@@ -1,32 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
2
- <configuration>
3
- <system.serviceModel>
4
-
5
- <bindings>
6
- <!-- Application Binding -->
7
- <webHttpRelayBinding>
8
- <binding name="default" />
9
- </webHttpRelayBinding>
10
- </bindings>
11
-
12
- <services>
13
- <!-- Application Service -->
14
- <service name="DotNetServicesRuby.ResourceService"
15
- behaviorConfiguration="default">
16
- <endpoint contract="DotNetServicesRuby.ResourceContract"
17
- binding="webHttpRelayBinding"
18
- bindingConfiguration="default"
19
- address="" />
20
- </service>
21
- </services>
22
-
23
- <behaviors>
24
- <serviceBehaviors>
25
- <behavior name="default">
26
- <serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false" />
27
- </behavior>
28
- </serviceBehaviors>
29
- </behaviors>
30
-
31
- </system.serviceModel>
32
- </configuration>
@@ -1,37 +0,0 @@
1
- namespace DotNetServicesRuby
2
- {
3
- using System;
4
- using System.Runtime.Serialization;
5
- using System.ServiceModel;
6
- using System.ServiceModel.Web;
7
- using System.ServiceModel.Channels;
8
-
9
- [ServiceContract]
10
- [ServiceBehavior]
11
- class PlainTextService
12
- {
13
- [OperationContract(Action="*", ReplyAction="*")]
14
- [WebInvoke(BodyStyle=WebMessageBodyStyle.Bare)]
15
- //public string Process(string foo)
16
- //{
17
- // return "hi mom";
18
- //}
19
-
20
- public Message Process(Message message)
21
- {
22
- var httpRequest = (HttpRequestMessageProperty)(message.Properties["httpRequest"]);
23
-
24
- var query = httpRequest.QueryString;
25
- var verb = httpRequest.Method;
26
- var body = "";
27
-
28
- Message response = Message.CreateMessage(MessageVersion.None, "GETRESPONSE", "hi, mom");
29
-
30
- HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty();
31
- responseProperty.Headers.Add("Content-Type", "text/plain");
32
- response.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);
33
- return response;
34
- }
35
-
36
- }
37
- }
@@ -1,49 +0,0 @@
1
- namespace DotNetServicesRuby
2
- {
3
- using System;
4
- using System.ServiceModel;
5
- using System.ServiceModel.Web;
6
- using System.ServiceModel.Description;
7
- using Microsoft.ServiceBus;
8
-
9
- class Program
10
- {
11
- static void Main(string[] args)
12
- {
13
-
14
- System.Console.WriteLine("Enter solution name: ");
15
- var solutionName = System.Console.ReadLine();
16
- System.Console.WriteLine("Enter password for " + solutionName + " solution:");
17
- var password = System.Console.ReadLine();
18
-
19
- var behavior = new TransportClientEndpointBehavior();
20
- behavior.CredentialType = TransportClientCredentialType.UserNamePassword;
21
- behavior.Credentials.UserName.UserName = solutionName;
22
- behavior.Credentials.UserName.Password = password;
23
-
24
- var address = new Uri(String.Format("http://{0}/services/{1}/TestService/", ServiceBusEnvironment.DefaultRelayHostName, solutionName));
25
- var host = new ServiceHost(typeof(ResourceService), address);
26
- host.Description.Endpoints[0].Behaviors.Add(behavior);
27
- host.Open();
28
-
29
- //var anonymousAddress = new Uri(String.Format("http://{0}/services/{1}/AnonymousTestService/", ServiceBusEnvironment.DefaultRelayHostName, solutionName));
30
- //var anonymousHost = new ServiceHost(typeof(AnonymousResourceService), anonymousAddress);
31
- //anonymousHost.Description.Endpoints[0].Behaviors.Add(behavior);
32
- //anonymousHost.Open();
33
-
34
- //var plainTextAddress = new Uri(String.Format("http://{0}/services/{1}/PlainTextTestService/", ServiceBusEnvironment.DefaultRelayHostName, solutionName));
35
- //var plainTextHost = new WebServiceHost(typeof(PlainTextService), plainTextAddress);
36
- //plainTextHost.Description.Endpoints[0].Behaviors.Add(behavior);
37
- //plainTextHost.Open();
38
-
39
- Console.WriteLine("Service address: " + address);
40
- Console.WriteLine("Press [Enter] to exit");
41
- Console.ReadLine();
42
-
43
- host.Close();
44
- //anonymousHost.Close();
45
- //plainTextHost.Close();
46
- }
47
-
48
- }
49
- }
@@ -1,33 +0,0 @@
1
- using System.Reflection;
2
- using System.Runtime.CompilerServices;
3
- using System.Runtime.InteropServices;
4
-
5
- // General Information about an assembly is controlled through the following
6
- // set of attributes. Change these attribute values to modify the information
7
- // associated with an assembly.
8
- [assembly: AssemblyTitle("Service")]
9
- [assembly: AssemblyDescription("")]
10
- [assembly: AssemblyConfiguration("")]
11
- [assembly: AssemblyCompany("")]
12
- [assembly: AssemblyProduct("Service")]
13
- [assembly: AssemblyCopyright("Copyright © 2006")]
14
- [assembly: AssemblyTrademark("")]
15
- [assembly: AssemblyCulture("")]
16
-
17
- // Setting ComVisible to false makes the types in this assembly not visible
18
- // to COM components. If you need to access a type in this assembly from
19
- // COM, set the ComVisible attribute to true on that type.
20
- [assembly: ComVisible(false)]
21
-
22
- // The following GUID is for the ID of the typelib if this project is exposed to COM
23
- [assembly: Guid("23fce5dd-8bf8-403c-b748-d24504e7c5c1")]
24
-
25
- // Version information for an assembly consists of the following four values:
26
- //
27
- // Major Version
28
- // Minor Version
29
- // Build Number
30
- // Revision
31
- //
32
- [assembly: AssemblyVersion("1.0.0.0")]
33
- [assembly: AssemblyFileVersion("1.0.0.0")]
@@ -1,17 +0,0 @@
1
- namespace DotNetServicesRuby
2
- {
3
- using System;
4
- using System.Runtime.Serialization;
5
- using System.ServiceModel;
6
- using System.ServiceModel.Web;
7
- using System.ServiceModel.Channels;
8
-
9
- [ServiceContract(Name = "ResourceContract", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
10
- public interface ResourceContract
11
- {
12
- [OperationContract(Action = "*", ReplyAction = "*")]
13
- Message Process(Message message);
14
- }
15
-
16
- public interface ResourceChannel : ResourceContract, IClientChannel { }
17
- }
@@ -1,58 +0,0 @@
1
- namespace DotNetServicesRuby
2
- {
3
- using System;
4
- using System.Collections.Generic;
5
- using System.ServiceModel;
6
- using System.ServiceModel.Channels;
7
-
8
- [ServiceBehavior(Name = "SyndicationService", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
9
- class ResourceService : ResourceContract
10
- {
11
- class HimomBodyWriter : BodyWriter
12
- {
13
- string query;
14
- string verb;
15
- string body;
16
-
17
- public HimomBodyWriter(string theQuery, string theVerb, string theBody) : base(true)
18
- {
19
- query = theQuery;
20
- verb = theVerb;
21
- body = theBody;
22
- }
23
-
24
- protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
25
- {
26
- writer.WriteStartElement("body");
27
- writer.WriteString("\n");
28
- writer.WriteString("Hi, mom\n");
29
- writer.WriteString("verb: " + verb + "\n");
30
- writer.WriteString("query: " + query + "\n");
31
- writer.WriteString("body: " + body + "\n");
32
- writer.WriteEndElement();
33
- }
34
- }
35
-
36
- public Message Process(Message message)
37
- {
38
- var httpRequest = (HttpRequestMessageProperty)(message.Properties["httpRequest"]);
39
-
40
- var query = httpRequest.QueryString;
41
- var verb = httpRequest.Method;
42
- var body = "";
43
-
44
- Message response = Message.CreateMessage(message.Version, "GETRESPONSE", new HimomBodyWriter(query, verb, body));
45
-
46
- HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty();
47
- responseProperty.Headers.Add("Content-Type", "application/xml; charset=utf-8");
48
- response.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);
49
- return response;
50
- }
51
-
52
- public Message ProcessPost(Message message)
53
- {
54
- throw new NotImplementedException();
55
- }
56
-
57
- }
58
- }
@@ -1,71 +0,0 @@
1
- <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
2
- <PropertyGroup>
3
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5
- <ProductVersion>9.0.21022</ProductVersion>
6
- <SchemaVersion>2.0</SchemaVersion>
7
- <ProjectGuid>{27CF1BE6-0280-46F8-BB19-BC7147E02B6A}</ProjectGuid>
8
- <OutputType>Exe</OutputType>
9
- <AppDesignerFolder>Properties</AppDesignerFolder>
10
- <RootNamespace>System.ServiceBus.Samples</RootNamespace>
11
- <AssemblyName>Service</AssemblyName>
12
- <FileUpgradeFlags>
13
- </FileUpgradeFlags>
14
- <OldToolsVersion>2.0</OldToolsVersion>
15
- <UpgradeBackupLocation>
16
- </UpgradeBackupLocation>
17
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
18
- </PropertyGroup>
19
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20
- <DebugSymbols>true</DebugSymbols>
21
- <DebugType>full</DebugType>
22
- <Optimize>false</Optimize>
23
- <OutputPath>bin\Debug\</OutputPath>
24
- <DefineConstants>DEBUG;TRACE</DefineConstants>
25
- <ErrorReport>prompt</ErrorReport>
26
- <WarningLevel>4</WarningLevel>
27
- </PropertyGroup>
28
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29
- <DebugType>pdbonly</DebugType>
30
- <Optimize>true</Optimize>
31
- <OutputPath>bin\Release\</OutputPath>
32
- <DefineConstants>TRACE</DefineConstants>
33
- <ErrorReport>prompt</ErrorReport>
34
- <WarningLevel>4</WarningLevel>
35
- </PropertyGroup>
36
- <ItemGroup>
37
- <Reference Include="Microsoft.ServiceBus, Version=0.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
38
- <Reference Include="System" />
39
- <Reference Include="System.Core">
40
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
41
- </Reference>
42
- <Reference Include="System.Data" />
43
- <Reference Include="System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
44
- <SpecificVersion>False</SpecificVersion>
45
- </Reference>
46
- <Reference Include="System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
47
- <Reference Include="System.ServiceModel.Web">
48
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
49
- </Reference>
50
- <Reference Include="System.Xml" />
51
- </ItemGroup>
52
- <ItemGroup>
53
- <Compile Include="AnonymousResourceService.cs" />
54
- <Compile Include="PlainTextService.cs" />
55
- <Compile Include="Program.cs" />
56
- <Compile Include="Properties\AssemblyInfo.cs" />
57
- <Compile Include="ResourceContract.cs" />
58
- <Compile Include="ResourceService.cs" />
59
- </ItemGroup>
60
- <ItemGroup>
61
- <None Include="App.config" />
62
- </ItemGroup>
63
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
64
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
65
- Other similar extension points exist, see Microsoft.Common.targets.
66
- <Target Name="BeforeBuild">
67
- </Target>
68
- <Target Name="AfterBuild">
69
- </Target>
70
- -->
71
- </Project>
@@ -1,33 +0,0 @@
1
- 
2
- Microsoft Visual Studio Solution File, Format Version 10.00
3
- # Visual Studio 2008
4
- Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F20C1D91-6F22-4047-85D9-423AB58D1C5C}"
5
- ProjectSection(SolutionItems) = preProject
6
- Readme.htm = Readme.htm
7
- EndProjectSection
8
- ProjectSection(WebsiteProperties) = preProject
9
- Debug.AspNetCompiler.Debug = "True"
10
- Release.AspNetCompiler.Debug = "False"
11
- EndProjectSection
12
- EndProject
13
- Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service", "Service\Service.csproj", "{27CF1BE6-0280-46F8-BB19-BC7147E02B6A}"
14
- ProjectSection(WebsiteProperties) = preProject
15
- Debug.AspNetCompiler.Debug = "True"
16
- Release.AspNetCompiler.Debug = "False"
17
- EndProjectSection
18
- EndProject
19
- Global
20
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
21
- Debug|Any CPU = Debug|Any CPU
22
- Release|Any CPU = Release|Any CPU
23
- EndGlobalSection
24
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
25
- {27CF1BE6-0280-46F8-BB19-BC7147E02B6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26
- {27CF1BE6-0280-46F8-BB19-BC7147E02B6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
27
- {27CF1BE6-0280-46F8-BB19-BC7147E02B6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
28
- {27CF1BE6-0280-46F8-BB19-BC7147E02B6A}.Release|Any CPU.Build.0 = Release|Any CPU
29
- EndGlobalSection
30
- GlobalSection(SolutionProperties) = preSolution
31
- HideSolutionNode = FALSE
32
- EndGlobalSection
33
- EndGlobal
@@ -1,84 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../spec_helper"
2
-
3
- describe "end to end usage scenarios" do
4
-
5
- it "should be able to perform a simple GET from the endpoint" do
6
- result = DotNetServices::Session.open(anonymous_test_endpoint) { |s| s.get }
7
- result.class.to_s.should == "Net::HTTPOK"
8
- result.content_type.should == 'application/xml'
9
- result.body.should =~ /^Hi, mom$/
10
- end
11
-
12
- it "should pass query string through a GET correctly" do
13
- result = DotNetServices::Session.open(anonymous_test_endpoint) { |s| s.get :foo => 'bar' }
14
- result.class.to_s.should == "Net::HTTPOK"
15
- result.content_type.should == 'application/xml'
16
- result.body.should =~ /^query: foo=bar/
17
- end
18
-
19
- it "should pass query string with URL escaped characters through a GET correctly" do
20
- result = DotNetServices::Session.open(anonymous_test_endpoint) { |s| s.get :foo => 'b+a~r+' }
21
- result.class.to_s.should == "Net::HTTPOK"
22
- result.content_type.should == 'application/xml'
23
- result.body.should =~ /^query: foo=b\+a~r/
24
- end
25
-
26
- # This scenario doesn't work, known bug in CTP 12
27
- # it "should pass a form data through a POST" do
28
- # result = DotNetServices::Session.open(test_endpoint) { |s| s.post :foo => 'bar' }
29
- # result.class.to_s.should == "Net::HTTPOK"
30
- # result.content_type.should == 'application/xml'
31
- # result.body.should =~ /^verb: POST$/
32
- # result.body.should =~ /^body: foo=bar$/
33
- # end
34
-
35
- it "should obtain a security token" do
36
- DotNetServices::Session.open(test_endpoint, :username => 'alexeyv', :password => '12345678') do
37
- |session|
38
- session.authenticator.token.should_not be_nil
39
- end
40
- end
41
-
42
- it "should be able to do an authenticated GET" do
43
- result = DotNetServices::Session.open(test_endpoint, :username => 'alexeyv', :password => '12345678') { |s| s.get }
44
- result.class.to_s.should == "Net::HTTPOK"
45
- result.body.should =~ /^Hi, mom$/
46
- # TODO: once we know how, make sure that service has some idea of who is talking to it
47
- end
48
-
49
- it "should pass a form data through an authenticated POST" do
50
- result = DotNetServices::Session.open(test_endpoint, :username => 'alexeyv', :password => '12345678') { |s| s.post :foo => 'bar' }
51
- result.class.to_s.should == "Net::HTTPOK"
52
- result.content_type.should == 'application/xml'
53
- result.body.should =~ /^verb: POST$/
54
- result.body.should =~ /^body: foo=bar$/
55
- end
56
-
57
- it "plain text GET" do
58
- result = DotNetServices::Session.open(plain_text_test_endpoint, :username => 'alexeyv', :password => '12345678') { |s| s.get :foo => 'bar' }
59
- result.class.to_s.should == "Net::HTTPOK"
60
- result.body.should == "hi mom"
61
- end
62
-
63
- it "plain text POST" do
64
- result = DotNetServices::Session.open(plain_text_test_endpoint, :username => 'alexeyv', :password => '12345678') { |s| s.post :foo => 'bar' }
65
- result.class.to_s.should == "Net::HTTPOK"
66
- result.content_type.should == 'text/plain'
67
- result.body.should =~ /^verb: POST$/
68
- result.body.should =~ /^body: foo=bar$/
69
- end
70
-
71
- it "should detect an invalid user/password situation and blow up correctly"
72
-
73
-
74
- # it "should not be slow as a turtle with laryngitis walking through molasses in January" do
75
- # start = Time.now
76
- # 10.times { DotNetServices::Session.open(anonymous_test_endpoint) { |s| s.get :foo => 'bar' } }
77
- # duration = Time.now - start
78
- #
79
- # if duration > 10
80
- # raise "10 simple get requests took #{duration} seconds to perform. This is too long."
81
- # end
82
- # end
83
-
84
- end
@@ -1,30 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../spec_helper"
2
-
3
- describe "end to end usage scenarios" do
4
-
5
- it "should do end-to-end VMB interaction with itself" do
6
- authenticator = DotNetServices::Authentication.setup(:username => 'RubyInterop', :password => '12345678')
7
- authenticator.authenticate
8
- authenticator.token.should_not be_nil
9
-
10
- create_request = Net::HTTP::CreateMB.new("/services/RubyInterop/MessageBuffer")
11
-
12
- authenticator.enhance(create_request)
13
-
14
- puts
15
- p create_request
16
- create_request.each { |k, v| puts "#{k}: #{v}"}
17
- puts
18
-
19
- result = Net::HTTP.start(DotNetServices.relay_host) { |http| http.request(create_request) }
20
-
21
- p result
22
- puts
23
- result.each { |k, v| puts "#{k}: #{v}"}
24
- puts
25
- puts result.body
26
- puts
27
-
28
- end
29
-
30
- end
data/spec/spec_helper.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'rubygems'
2
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
3
-
4
- require 'spec'
5
- require 'dot_net_services'
6
-
7
- Spec::Runner.configure do |config|
8
- config.before(:each) do
9
- DotNetServices::Authentication.clear_cache!
10
- end
11
- end
12
-
13
- def test_endpoint
14
- DotNetServices.root_url + "/BillBoard/TestService/"
15
- end
16
-
17
- def anonymous_test_endpoint
18
- DotNetServices.root_url + "/BillBoard/AnonymousTestService/"
19
- end
20
-
21
- def plain_text_test_endpoint
22
- DotNetServices.root_url + "/BillBoard/PlainTextTestService/"
23
- end