ruby_odata 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module OData
2
+ VERSION = "0.0.8"
3
+ end
@@ -1,85 +1,31 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ruby_odata/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{ruby_odata}
8
- s.version = "0.0.7"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Damien White"]
12
- s.date = %q{2010-07-04}
6
+ s.name = "ruby_odata"
7
+ s.version = OData::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Damien White"]
10
+ s.email = ["damien.white@visoftinc.com"]
11
+ s.homepage = %q{http://github.com/visoft/ruby_odata}
12
+ s.summary = %q{Ruby consumer of OData services.}
13
13
  s.description = %q{An OData Client Library for Ruby. Use this to interact with OData services}
14
- s.email = %q{damien.white@visoftinc.com}
15
- s.extra_rdoc_files = [
16
- "CHANGELOG.rdoc",
17
- "LICENSE",
18
- "README.rdoc"
19
- ]
20
- s.files = [
21
- ".gitignore",
22
- "CHANGELOG.rdoc",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "config/cucumber.yml",
28
- "features/batch_request.feature",
29
- "features/complex_types.feature",
30
- "features/query_builder.feature",
31
- "features/service.feature",
32
- "features/service_manage.feature",
33
- "features/step_definitions/service_steps.rb",
34
- "features/support/env.rb",
35
- "features/support/hooks.rb",
36
- "features/type_conversion.feature",
37
- "lib/ruby_odata.rb",
38
- "lib/ruby_odata/class_builder.rb",
39
- "lib/ruby_odata/operation.rb",
40
- "lib/ruby_odata/query_builder.rb",
41
- "lib/ruby_odata/service.rb",
42
- "ruby_odata.gemspec",
43
- "test/Cassini x64.bat",
44
- "test/Cassini x86.bat",
45
- "test/SampleService/App_Code/AuditFields.cs",
46
- "test/SampleService/App_Code/Entities.cs",
47
- "test/SampleService/App_Code/Model.Designer.cs",
48
- "test/SampleService/App_Code/Model.edmx",
49
- "test/SampleService/App_Code/ModelContainerExtended.cs",
50
- "test/SampleService/App_Data/_TestDB.mdf",
51
- "test/SampleService/App_Data/_TestDB_Log.ldf",
52
- "test/SampleService/Entities.svc",
53
- "test/SampleService/web.config",
54
- "test/blueprints.rb"
55
- ]
56
- s.homepage = %q{http://github.com/visoft/ruby_odata}
57
- s.rdoc_options = ["--charset=UTF-8"]
58
- s.require_paths = ["lib"]
59
- s.rubyforge_project = %q{ruby-odata}
60
- s.rubygems_version = %q{1.3.7}
61
- s.summary = %q{Ruby consumer of OData services.}
62
- s.test_files = [
63
- "test/blueprints.rb"
64
- ]
65
14
 
66
- if s.respond_to? :specification_version then
67
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
68
- s.specification_version = 3
15
+ s.rubyforge_project = "ruby-odata"
69
16
 
70
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
71
- s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
72
- s.add_runtime_dependency(%q<rest-client>, [">= 1.5.1"])
73
- s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.2"])
74
- else
75
- s.add_dependency(%q<activesupport>, [">= 2.3.5"])
76
- s.add_dependency(%q<rest-client>, [">= 1.5.1"])
77
- s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
78
- end
79
- else
80
- s.add_dependency(%q<activesupport>, [">= 2.3.5"])
81
- s.add_dependency(%q<rest-client>, [">= 1.5.1"])
82
- s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
83
- end
84
- end
17
+ s.add_dependency('activesupport', '>= 2.3.5')
18
+ s.add_dependency('rest-client', '>= 1.5.1')
19
+ s.add_dependency('nokogiri', '>= 1.4.2')
20
+
21
+ s.add_development_dependency('rspec')
22
+ s.add_development_dependency('cucumber')
23
+ s.add_development_dependency('sham')
24
+ s.add_development_dependency('faker')
25
+ s.add_development_dependency('machinist')
85
26
 
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
+ s.require_paths = ["lib"]
31
+ end
@@ -3,6 +3,10 @@ using System.Data.Services.Common;
3
3
  using System.ServiceModel;
4
4
  using System.ServiceModel.Web;
5
5
  using System.Web;
6
+ using System;
7
+ using System.Linq;
8
+ using System.Security.Principal;
9
+ using System.Text;
6
10
  using Model;
7
11
 
8
12
  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
@@ -29,14 +33,113 @@ public class Entities : DataService< ModelContainer >
29
33
  context.ExecuteStoreCommand("ALTER TABLE [dbo].[Products] ADD CONSTRAINT [FK_CategoryProduct] FOREIGN KEY ([Category_Id]) REFERENCES [dbo].[Categories]([Id])");
30
34
 
31
35
  }
32
-
36
+
33
37
  protected override void OnStartProcessingRequest(ProcessRequestArgs args)
34
38
  {
35
39
  base.OnStartProcessingRequest(args);
36
40
  if (args.RequestUri.AbsoluteUri.ToLower().EndsWith("cleandatabasefortesting"))
37
41
  {
38
- if (HttpContext.Current.Request.UserHostAddress != "127.0.0.1")
42
+ var hostAddress = HttpContext.Current.Request.UserHostAddress;
43
+ if (hostAddress != "127.0.0.1" && hostAddress != "::1")
39
44
  throw new DataServiceException(401, "Access Denied");
40
45
  }
41
46
  }
42
47
  }
48
+
49
+ public class OurBasicAuthenticationModule: IHttpModule
50
+ {
51
+ public void Init(HttpApplication context)
52
+ {
53
+ context.AuthenticateRequest
54
+ += new EventHandler(context_AuthenticateRequest);
55
+ }
56
+
57
+ void context_AuthenticateRequest(object sender, EventArgs e)
58
+ {
59
+ HttpApplication application = (HttpApplication)sender;
60
+
61
+ // Only require authentication if BasicAuth is in the URI path
62
+ if (( application.Context.Request.Url.AbsoluteUri.Contains("BasicAuth")) &&
63
+ (!CustomBasicAuthenticationProvider.Authenticate(application.Context)))
64
+ {
65
+ application.Context.Response.Status = "401 Unauthorized";
66
+ application.Context.Response.StatusCode = 401;
67
+ application.Context.Response.AddHeader("WWW-Authenticate", "Basic");
68
+ application.CompleteRequest();
69
+ }
70
+ }
71
+
72
+ public void Dispose() { }
73
+
74
+ } // class OurBasicAuthenticationModule: IHttpModule
75
+
76
+ public class CustomBasicAuthenticationProvider
77
+ {
78
+ public static bool Authenticate(HttpContext context)
79
+ {
80
+ if (!HttpContext.Current.Request.Headers.AllKeys.Contains("Authorization"))
81
+ return false;
82
+
83
+ string authHeader = HttpContext.Current.Request.Headers["Authorization"];
84
+
85
+ IPrincipal principal;
86
+ if (TryGetPrincipal(authHeader, out principal))
87
+ {
88
+ HttpContext.Current.User = principal;
89
+ return true;
90
+ }
91
+ return false;
92
+ }
93
+
94
+ private static bool TryGetPrincipal(string authHeader, out IPrincipal principal)
95
+ {
96
+ var creds = ParseAuthHeader(authHeader);
97
+ if (creds != null && TryGetPrincipal(creds, out principal))
98
+ return true;
99
+
100
+ principal = null;
101
+ return false;
102
+ }
103
+
104
+ private static bool TryGetPrincipal(string[] creds,out IPrincipal principal)
105
+ {
106
+ if (creds[0] == "admin" && creds[1] == "passwd")
107
+ {
108
+ principal = new GenericPrincipal(
109
+ new GenericIdentity("Administrator"),
110
+ new string[] {"Administrator", "User"}
111
+ );
112
+ return true;
113
+ }
114
+ else
115
+ {
116
+ principal = null;
117
+ return false;
118
+ }
119
+ }
120
+
121
+ private static string[] ParseAuthHeader(string authHeader)
122
+ {
123
+ // Check this is a Basic Auth header
124
+ if (
125
+ authHeader == null ||
126
+ authHeader.Length == 0 ||
127
+ !authHeader.StartsWith("Basic")
128
+ ) return null;
129
+
130
+ // Pull out the Credentials with are seperated by ':' and Base64 encoded
131
+ // Won't handle password with : in it, but that's OK for these tests
132
+ string base64Credentials = authHeader.Substring(6);
133
+ string[] credentials = Encoding.ASCII.GetString(
134
+ Convert.FromBase64String(base64Credentials)
135
+ ).Split(new char[] { ':' });
136
+
137
+ if (credentials.Length != 2 ||
138
+ string.IsNullOrEmpty(credentials[0]) ||
139
+ string.IsNullOrEmpty(credentials[0])
140
+ ) return null;
141
+
142
+ return credentials;
143
+ }
144
+
145
+ } // class CustomBasicAuthenticationProvider
@@ -365,6 +365,30 @@ namespace Model
365
365
  private global::System.Decimal _Price;
366
366
  partial void OnPriceChanging(global::System.Decimal value);
367
367
  partial void OnPriceChanged();
368
+
369
+ /// <summary>
370
+ /// No Metadata Documentation available.
371
+ /// </summary>
372
+ [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
373
+ [DataMemberAttribute()]
374
+ public Nullable<global::System.DateTime> DiscontinuedDate
375
+ {
376
+ get
377
+ {
378
+ return _DiscontinuedDate;
379
+ }
380
+ set
381
+ {
382
+ OnDiscontinuedDateChanging(value);
383
+ ReportPropertyChanging("DiscontinuedDate");
384
+ _DiscontinuedDate = StructuralObject.SetValidValue(value);
385
+ ReportPropertyChanged("DiscontinuedDate");
386
+ OnDiscontinuedDateChanged();
387
+ }
388
+ }
389
+ private Nullable<global::System.DateTime> _DiscontinuedDate;
390
+ partial void OnDiscontinuedDateChanging(Nullable<global::System.DateTime> value);
391
+ partial void OnDiscontinuedDateChanged();
368
392
 
369
393
  #endregion
370
394
  #region Complex Properties
@@ -32,6 +32,7 @@
32
32
  <Property Name="CreateDate" Type="datetime" Nullable="false" />
33
33
  <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
34
34
  <Property Name="CreatedBy" Type="nvarchar" MaxLength="50" />
35
+ <Property Name="DiscontinuedDate" Type="datetime" />
35
36
  </EntityType>
36
37
  <Association Name="FK_CategoryProduct">
37
38
  <End Role="Categories" Type="Model.Store.Categories" Multiplicity="1" />
@@ -67,6 +68,7 @@
67
68
  <Property Type="Decimal" Name="Price" Nullable="false" />
68
69
  <NavigationProperty Name="Category" Relationship="Model.CategoryProduct" FromRole="Product" ToRole="Category" />
69
70
  <Property Name="AuditFields" Type="Model.AuditFields" Nullable="false" />
71
+ <Property Type="DateTime" Name="DiscontinuedDate" Nullable="true" />
70
72
  </EntityType>
71
73
  <EntityType Name="Category">
72
74
  <Key>
@@ -94,6 +96,7 @@
94
96
  <EntitySetMapping Name="Products">
95
97
  <EntityTypeMapping TypeName="IsTypeOf(Model.Product)">
96
98
  <MappingFragment StoreEntitySet="Products">
99
+ <ScalarProperty Name="DiscontinuedDate" ColumnName="DiscontinuedDate" />
97
100
  <ScalarProperty Name="Id" ColumnName="Id" />
98
101
  <ScalarProperty Name="Name" ColumnName="Name" />
99
102
  <ScalarProperty Name="Description" ColumnName="Description" />
@@ -0,0 +1 @@
1
+ <%@ ServiceHost Language="C#" Factory="System.Data.Services.DataServiceHostFactory" Service="Entities" %>
@@ -4,6 +4,14 @@
4
4
  http://go.microsoft.com/fwlink/?LinkId=169433
5
5
  -->
6
6
  <configuration>
7
+
8
+ <system.webServer>
9
+ <modules>
10
+ <add name="OurBasicAuthenticationModule"
11
+ type="OurBasicAuthenticationModule"/>
12
+ </modules>
13
+ </system.webServer>
14
+
7
15
  <system.web>
8
16
  <compilation debug="true" targetFramework="4.0">
9
17
  <assemblies>
@@ -24,4 +32,6 @@
24
32
  <system.serviceModel>
25
33
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
26
34
  </system.serviceModel>
27
- </configuration>
35
+ </configuration>
36
+
37
+
@@ -1,21 +1,21 @@
1
- Sham.define do
2
- category_name { |i| "Category #{i}" }
3
- product_name { |i| "Widget #{i}" }
4
- price(:unique => false) { ['5.00', '10.00', '20.00', '15.00' , '25.00', '7.50'].rand }
5
- end
6
-
7
- Product.blueprint do
8
- Name { Sham.product_name }
9
- Description "Test Widget"
10
- Price { Sham.price }
11
- Category { Category.make }
12
- AuditFields { AuditFields.make }
13
- end
14
-
15
- Category.blueprint do
16
- Name { Sham.category_name }
17
- end
18
-
19
- AuditFields.blueprint do
20
- CreatedBy "Cucumber"
1
+ Sham.define do
2
+ category_name { |i| "Category #{i}" }
3
+ product_name { |i| "Widget #{i}" }
4
+ price(:unique => false) { ['5.00', '10.00', '20.00', '15.00' , '25.00', '7.50'].rand }
5
+ end
6
+
7
+ Product.blueprint do
8
+ Name { Sham.product_name }
9
+ Description "Test Widget"
10
+ Price { Sham.price }
11
+ Category { Category.make }
12
+ AuditFields { AuditFields.make }
13
+ end
14
+
15
+ Category.blueprint do
16
+ Name { Sham.category_name }
17
+ end
18
+
19
+ AuditFields.blueprint do
20
+ CreatedBy "Cucumber"
21
21
  end
@@ -0,0 +1 @@
1
+ "%ProgramFiles(x86)%\iis express\iisexpress" /port:8888 /path:"%~dp0SampleService" /vpath:"/SampleService"
@@ -0,0 +1 @@
1
+ "%ProgramFiles%\iis express\iisexpress" /port:8888 /path:"%~dp0SampleService" /vpath:"/SampleService"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_odata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Damien White
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-04 00:00:00 -04:00
18
+ date: 2011-03-12 23:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -66,24 +66,94 @@ dependencies:
66
66
  version: 1.4.2
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ type: :development
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: cucumber
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ name: sham
99
+ prerelease: false
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ type: :development
110
+ version_requirements: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ name: faker
113
+ prerelease: false
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ type: :development
124
+ version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ name: machinist
127
+ prerelease: false
128
+ requirement: &id008 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 3
134
+ segments:
135
+ - 0
136
+ version: "0"
137
+ type: :development
138
+ version_requirements: *id008
69
139
  description: An OData Client Library for Ruby. Use this to interact with OData services
70
- email: damien.white@visoftinc.com
140
+ email:
141
+ - damien.white@visoftinc.com
71
142
  executables: []
72
143
 
73
144
  extensions: []
74
145
 
75
- extra_rdoc_files:
76
- - CHANGELOG.rdoc
77
- - LICENSE
78
- - README.rdoc
146
+ extra_rdoc_files: []
147
+
79
148
  files:
80
149
  - .gitignore
81
150
  - CHANGELOG.rdoc
151
+ - Gemfile
82
152
  - LICENSE
83
153
  - README.rdoc
84
154
  - Rakefile
85
- - VERSION
86
155
  - config/cucumber.yml
156
+ - features/basic_auth.feature
87
157
  - features/batch_request.feature
88
158
  - features/complex_types.feature
89
159
  - features/query_builder.feature
@@ -98,6 +168,7 @@ files:
98
168
  - lib/ruby_odata/operation.rb
99
169
  - lib/ruby_odata/query_builder.rb
100
170
  - lib/ruby_odata/service.rb
171
+ - lib/ruby_odata/version.rb
101
172
  - ruby_odata.gemspec
102
173
  - test/Cassini x64.bat
103
174
  - test/Cassini x86.bat
@@ -108,16 +179,19 @@ files:
108
179
  - test/SampleService/App_Code/ModelContainerExtended.cs
109
180
  - test/SampleService/App_Data/_TestDB.mdf
110
181
  - test/SampleService/App_Data/_TestDB_Log.ldf
182
+ - test/SampleService/BasicAuth/Entities.svc
111
183
  - test/SampleService/Entities.svc
112
184
  - test/SampleService/web.config
113
185
  - test/blueprints.rb
186
+ - test/iisExpress x64.bat
187
+ - test/iisExpress x86.bat
114
188
  has_rdoc: true
115
189
  homepage: http://github.com/visoft/ruby_odata
116
190
  licenses: []
117
191
 
118
192
  post_install_message:
119
- rdoc_options:
120
- - --charset=UTF-8
193
+ rdoc_options: []
194
+
121
195
  require_paths:
122
196
  - lib
123
197
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -145,5 +219,5 @@ rubygems_version: 1.3.7
145
219
  signing_key:
146
220
  specification_version: 3
147
221
  summary: Ruby consumer of OData services.
148
- test_files:
149
- - test/blueprints.rb
222
+ test_files: []
223
+