Permalink
Browse files

Modified test files to allow for more flexiblity in where the WCF ser…

…vice is located
  • Loading branch information...
1 parent d8a4385 commit 228f99a1f2355768e6a85a6c7a93808af5236ae3 @visoft committed Nov 10, 2011
View
3 .gitignore
@@ -12,4 +12,5 @@ doc/*
.bundle
Gemfile.lock
pkg/*
-test/applicationhost.config
+test/applicationhost.config
+.rvmrc
View
4 .travis.yml
@@ -0,0 +1,4 @@
+rvm:
+ - 1.8.7
+ - 1.9.2
+script: "bundle exec rake spec"
View
8 config/cucumber.yml
@@ -1,8 +1,8 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
-rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
-std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
+rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format pretty #{rerun}"
+std_opts = "--format progress features --tags ~@wip"
%>
-default: <%= std_opts %>
+default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
-rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
+rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
View
8 features/basic_auth.feature
@@ -1,7 +1,7 @@
Feature: Service Should Access Basic Auth Protected Resources
Background:
- Given an ODataService exists with uri: "http://localhost:8989/SampleService/BasicAuth/Entities.svc" using username "admin" and password "passwd"
+ Given a HTTP BasicAuth ODataService exists using username "admin" and password "passwd"
And blueprints exist for the service
Scenario: Service should respond to valid collections
@@ -16,9 +16,7 @@ Scenario: Entity should fill values on protected resource
And the method "Name" on the first result should equal: "Auth Test Category"
Scenario: Should get 401 if invalid credentials provided to protected URL
- Given an ODataService exists with uri: "http://localhost:8989/SampleService/BasicAuth/Entities.svc" using username "admin" and password "bad_pwd" it should throw an exception with message "401 Unauthorized"
+ Given a HTTP BasicAuth ODataService exists using username "admin" and password "bad_pwd" it should throw an exception with message "401 Unauthorized"
Scenario: Should get 401 if no credentials provided to protected URL
- Given an ODataService exists with uri: "http://localhost:8989/SampleService/BasicAuth/Entities.svc" it should throw an exception with message "401 Unauthorized"
-
-
+ Given a HTTP BasicAuth ODataService exists it should throw an exception with message "401 Unauthorized"
View
2 features/batch_request.feature
@@ -4,7 +4,7 @@ Feature: Batch request
I want to be able to batch changes (Add/Update/Delete) and persist the batch instead of one at a time
Background:
- Given a sample HTTP ODataService exists
+ Given a HTTP ODataService exists
And blueprints exist for the service
Scenario: Save Changes should allow for batch additions
View
2 features/complex_types.feature
@@ -4,7 +4,7 @@ Feature: Complex types
I want to be able to manage objects with complex types
Background:
- Given a sample HTTP ODataService exists
+ Given a HTTP ODataService exists
And blueprints exist for the service
Scenario: The proxy must generate classes for complex types if they exist
View
2 features/query_builder.feature
@@ -4,7 +4,7 @@ Feature: Query Builder
I want to be able to perform valid OData protocol operations
Background:
- Given a sample HTTP ODataService exists
+ Given a HTTP ODataService exists
And blueprints exist for the service
# Expand
View
2 features/service.feature
@@ -4,7 +4,7 @@ Feature: Service Should Generate a Proxy
I want to be able to access data
Background:
- Given a sample HTTP ODataService exists
+ Given a HTTP ODataService exists
And blueprints exist for the service
Scenario: Service should respond to valid collections
View
4 features/service_manage.feature
@@ -4,7 +4,7 @@ Feature: Service management
I want to be able to add, edit, and delete entities
Background:
- Given an ODataService exists with uri: "http://localhost:8989/SampleService/Entities.svc"
+ Given a HTTP ODataService exists
And blueprints exist for the service
Scenario: Service should respond to AddToEntityName for adding objects
@@ -51,4 +51,4 @@ Scenario: Related entities shouldn't be recreated on a child add
And I call "Products" on the service with args: "1"
And I expand the query to include "Category"
When I run the query
- Then the method "Id" on the result object's method "Category" should equal: "1"
+ Then the method "Id" on the result object's method "Category" should equal: "1"
View
4 features/ssl.feature
@@ -1,7 +1,7 @@
Feature: Service Should Access Basic Resources via SSL using a self-signed certificate
Background:
- Given an ODataService exists with uri: "https://localhost:44300/SampleService/BasicAuth/Entities.svc" using self-signed certificate and username "admin" and password "passwd"
+ Given a HTTPS BasicAuth ODataService exists using self-signed certificate and username "admin" and password "passwd"
And blueprints exist for the service
Scenario: Service should respond to valid collections
@@ -16,6 +16,6 @@ Scenario: Entity should fill values on protected resource
And the method "Name" on the first result should equal: "Auth Test Category"
Scenario: Should get SSL failure if SSL used with self-signed certificate and not passing "false" as :verify_ssl option
- Given an ODataService exists with uri: "https://localhost:44300/SampleService/Entities.svc" it should throw an exception with message containing "SSL Verification failed"
+ Given a HTTPS BasicAuth ODataService exists it should throw an exception with message containing "SSL Verification failed"
View
39 features/step_definitions/service_steps.rb
@@ -5,37 +5,48 @@ def first(results)
end
World(PositionHelpers)
+STANDARD_URL = "http://#{WEBSERVER}:#{HTTP_PORT_NUMBER}/SampleService/Entities.svc"
+BASICAUTH_URL = "http://#{WEBSERVER}:#{HTTP_PORT_NUMBER}/SampleService/BasicAuth/Entities.svc"
+HTTPS_BASICAUTH_URL = "https://#{WEBSERVER}:#{HTTPS_PORT_NUMBER}/SampleService/BasicAuth/Entities.svc"
+
When /^(.*) first (.*)$/ do |step, results|
first(results) { When step }
end
+Given /^a HTTP ODataService exists$/ do
+ @service = OData::Service.new(STANDARD_URL)
+end
+
+Given /^a HTTP BasicAuth ODataService exists$/ do
+ @service = OData::Service.new(BASICAUTH_URL)
+end
-Given /^an ODataService exists with uri: "([^\"]*)"$/ do |uri|
- @service = OData::Service.new(uri)
+Given /^a HTTPS BasicAuth ODataService exists$/ do
+ @service = OData::Service.new(HTTPS_BASICAUTH_URL)
end
-Given /^a sample HTTP ODataService exists$/ do
- @service = OData::Service.new("http://localhost:#{HTTP_PORT_NUMBER}/SampleService/Entities.svc")
+Given /^a HTTP BasicAuth ODataService exists using username "([^\"]*)" and password "([^\"]*)"$/ do |username, password|
+ @service = OData::Service.new(BASICAUTH_URL, { :username => username, :password => password })
end
-Given /^an ODataService exists with uri: "([^\"]*)" using username "([^\"]*)" and password "([^\"]*)"$/ do |uri, username, password|
- @service = OData::Service.new(uri, { :username => username, :password => password })
+Given /^a HTTP BasicAuth ODataService exists using username "([^\"]*)" and password "([^\"]*)" it should throw an exception with message "([^\"]*)"$/ do |username, password, msg|
+ lambda { @service = OData::Service.new(BASICAUTH_URL, { :username => username, :password => password }) }.should raise_error(msg)
end
-Given /^an ODataService exists with uri: "([^\"]*)" using username "([^\"]*)" and password "([^\"]*)" it should throw an exception with message "([^\"]*)"$/ do |uri, username, password, msg|
- lambda { @service = OData::Service.new(uri, { :username => username, :password => password }) }.should raise_error(msg)
+Given /^a HTTP BasicAuth ODataService exists it should throw an exception with message containing "([^\"]*)"$/ do |msg|
+ lambda { @service = OData::Service.new(BASICAUTH_URL) }.should raise_error(/#{msg}.*/)
end
-Given /^an ODataService exists with uri: "([^\"]*)" it should throw an exception with message containing "([^\"]*)"$/ do |uri, msg|
- lambda { @service = OData::Service.new(uri) }.should raise_error(/#{msg}.*/)
+Given /^a HTTPS BasicAuth ODataService exists it should throw an exception with message containing "([^"]*)"$/ do |msg|
+ lambda { @service = OData::Service.new(HTTPS_BASICAUTH_URL) }.should raise_error(/#{msg}.*/)
end
-Given /^an ODataService exists with uri: "([^\"]*)" it should throw an exception with message "([^\"]*)"$/ do |uri, msg|
- lambda { @service = OData::Service.new(uri) }.should raise_error(msg)
+Given /^a HTTP BasicAuth ODataService exists it should throw an exception with message "([^\"]*)"$/ do |msg|
+ lambda { @service = OData::Service.new(BASICAUTH_URL) }.should raise_error(msg)
end
-Given /^an ODataService exists with uri: "([^\"]*)" using self-signed certificate and username "([^\"]*)" and password "([^\"]*)"$/ do |uri, username, password|
- @service = OData::Service.new(uri, { :username => username, :password => password, :verify_ssl => false })
+Given /^a HTTPS BasicAuth ODataService exists using self-signed certificate and username "([^\"]*)" and password "([^\"]*)"$/ do |username, password|
+ @service = OData::Service.new(HTTPS_BASICAUTH_URL, { :username => username, :password => password, :verify_ssl => false })
end
When /^I call "([^\"]*)" on the service$/ do |method|
View
3 features/support/constants.rb
@@ -0,0 +1,3 @@
+HTTP_PORT_NUMBER = 8989
+HTTPS_PORT_NUMBER = 44300
+WEBSERVER = 'localhost'
View
4 features/support/env.rb
@@ -11,6 +11,4 @@
if !File.exists?("#{root_dir}/TestDB.mdf")
FileUtils.copy("#{root_dir}/_TestDB.mdf", "#{root_dir}/TestDB.mdf")
FileUtils.copy("#{root_dir}/_TestDB_Log.ldf", "#{root_dir}/TestDB_Log.ldf")
-end
-
-HTTP_PORT_NUMBER = 8989
+end
View
2 features/support/hooks.rb
@@ -1,4 +1,4 @@
Before do
Sham.reset
- RestClient.post "http://localhost:#{HTTP_PORT_NUMBER}/SampleService/Entities.svc/CleanDatabaseForTesting", {}
+ RestClient.post "http://#{WEBSERVER}:#{HTTP_PORT_NUMBER}/SampleService/Entities.svc/CleanDatabaseForTesting", {}
end
View
2 features/type_conversion.feature
@@ -4,7 +4,7 @@ Feature: Type conversion
I want types returned to be accurately represented
Background:
- Given a sample HTTP ODataService exists
+ Given a HTTP ODataService exists
And blueprints exist for the service
Scenario: Integers should be Fixnums
View
11 test/SampleService/App_Code/Entities.cs
@@ -33,17 +33,6 @@ public void CleanDatabaseForTesting()
context.ExecuteStoreCommand("ALTER TABLE [dbo].[Products] ADD CONSTRAINT [FK_CategoryProduct] FOREIGN KEY ([Category_Id]) REFERENCES [dbo].[Categories]([Id])");
}
-
- protected override void OnStartProcessingRequest(ProcessRequestArgs args)
- {
- base.OnStartProcessingRequest(args);
- if (args.RequestUri.AbsoluteUri.ToLower().EndsWith("cleandatabasefortesting"))
- {
- var hostAddress = HttpContext.Current.Request.UserHostAddress;
- if (hostAddress != "127.0.0.1" && hostAddress != "::1")
- throw new DataServiceException(401, "Access Denied");
- }
- }
}
public class OurBasicAuthenticationModule: IHttpModule
View
4 test/applicationhost.config.template
@@ -158,8 +158,8 @@
<virtualDirectory path="/" physicalPath="%SAMPLE_SERVICE_DIR%" />
</application>
<bindings>
- <binding protocol="http" bindingInformation=":8989:localhost" />
- <binding protocol="https" bindingInformation=":44300:localhost" />
+ <binding protocol="http" bindingInformation=":%HTTP_PORT_NUMBER%:%WEBSERVER%" />
+ <binding protocol="https" bindingInformation=":%HTTPS_PORT_NUMBER%:%WEBSERVER%" />
</bindings>
</site>
<siteDefaults>
View
16 test/setpath.rb
@@ -1,3 +1,13 @@
-# Open template config file and write in current directory to virtual path
-puts "Replacing %SAMPLE_SERVICE_DIR% with #{Dir.pwd}\\SampleService"
-File.open("applicationhost.config", "w") {|file| file.puts File.read("applicationhost.config.template").gsub("%SAMPLE_SERVICE_DIR%", "#{Dir.pwd.gsub("\/", "\\")}\\SampleService" ) }
+require File.expand_path('../../features/support/constants', __FILE__)
+
+# Open template config file and write in proper data
+puts "Replacing Configuration Data"
+File.open("applicationhost.config", "w") do |file|
+ File.open("applicationhost.config.template", 'r').each do |line|
+ line.gsub!("%SAMPLE_SERVICE_DIR%", "#{Dir.pwd.gsub("\/", "\\")}\\SampleService")
+ line.gsub!("%HTTP_PORT_NUMBER%", "#{HTTP_PORT_NUMBER}")
+ line.gsub!("%HTTPS_PORT_NUMBER%", "#{HTTPS_PORT_NUMBER}")
+ line.gsub!("%WEBSERVER%", "#{WEBSERVER}")
+ file.puts line
+ end
+end

0 comments on commit 228f99a

Please sign in to comment.