diff options
Diffstat (limited to 'features')
| -rw-r--r-- | features/anonymous.feature | 34 | ||||
| -rw-r--r-- | features/config.feature | 26 | ||||
| -rw-r--r-- | features/service.feature | 33 | ||||
| -rw-r--r-- | features/step_definitions/config_steps.rb | 22 | ||||
| -rw-r--r-- | features/support/hooks.rb | 6 | ||||
| -rw-r--r-- | features/unauthenticated.feature | 17 | 
6 files changed, 107 insertions, 31 deletions
| diff --git a/features/anonymous.feature b/features/anonymous.feature new file mode 100644 index 0000000..73a6d3f --- /dev/null +++ b/features/anonymous.feature @@ -0,0 +1,34 @@ +@config +Feature: Anonymous access to EIP + +  A provider may choose to allow anonymous access to EIP. +  In this case some endpoints that would normally require authentication +  will be available without authentication. + +  Background:  +    Given "allow_anonymous_certs" is enabled in the config +    And I set headers: +      | Accept       | application/json | +      | Content-Type | application/json | + +  Scenario: Fetch configs when anonymous certs are allowed +    When I send a GET request to "/1/configs.json" +    Then the response status should be "200" + +  Scenario: Fetch EIP config when anonymous certs are allowed +    Given there is a config for the eip +    When I send a GET request to "/1/configs/eip-service.json" +    Then the response status should be "200" + +  Scenario: Fetch service description +    When I send a GET request to "/1/service.json" +    Then the response status should be "200" +    And the response should be: +    """ +      { +        "name": "anonymous", +        "description": "anonymous access to the VPN", +        "eip_rate_limit": false +      } +    """ + diff --git a/features/config.feature b/features/config.feature index 6adaed9..0b2ee70 100644 --- a/features/config.feature +++ b/features/config.feature @@ -15,16 +15,10 @@ Feature: Download Provider Configuration    @tempfile    Scenario: Fetch provider config -    Given the provider config is: -      """ -      {"config": "me"} -      """ +    Given there is a config for the provider      When I send a GET request to "/provider.json"      Then the response status should be "200" -    And the response should be: -      """ -      {"config": "me"} -      """ +    And the response should be that config    Scenario: Missing provider config      When I send a GET request to "/provider.json" @@ -44,3 +38,19 @@ Feature: Download Provider Configuration          }        }        """ +   +  Scenario: Attempt to fetch an invalid config +    When I send a GET request to "/1/configs/non-existing.json" +    Then the response status should be "403" + +  Scenario: Attempt to fetch a config that is missing on the server +    When I send a GET request to "/1/configs/eip-service.json" +    Then the response status should be "404" + +  @tempfile, @config +  Scenario: Attempt to fetch the EIP config +    Given there is a config for the eip +    When I send a GET request to "/1/configs/eip-service.json" +    Then the response status should be "200" +    And the response should be that config + diff --git a/features/service.feature b/features/service.feature new file mode 100644 index 0000000..ea49c74 --- /dev/null +++ b/features/service.feature @@ -0,0 +1,33 @@ +Feature: Get service description for current user + +  The LEAP provider can offer different services and their availability may +  depend upon a users service level - so wether they are paying or not. + +  The /1/service endpoint allows the client to find out about the services +  available to the authenticated user. + +  Background: +    Given I authenticated +    Given I set headers: +      | Accept       | application/json | +      | Content-Type | application/json | +      | Authorization | Token token="MY_AUTH_TOKEN" | + +  Scenario: Get service settings +    When I send a GET request to "/1/service" +    Then the response status should be "200" +    And the response should be: +    """ +      { +        "name": "free", +        "description": "free account, with rate limited VPN", +        "eip_rate_limit": true, +        "storage": 100, +        "services": [ +          "eip" +        ] +      } +   """ + + + diff --git a/features/step_definitions/config_steps.rb b/features/step_definitions/config_steps.rb index 70ff1aa..1fc67f5 100644 --- a/features/step_definitions/config_steps.rb +++ b/features/step_definitions/config_steps.rb @@ -1,12 +1,20 @@ -Given /the provider config is:$/ do |config| -  @tempfile = Tempfile.new('provider.json') -  @tempfile.write config +# use with @tempfile, @config +Given /there is a config for the (.*)$/ do |config| +  @dummy_config = {dummy_config_for: config}.to_json +  @tempfile = Tempfile.new("#{config}.json") +  @tempfile.write @dummy_config    @tempfile.close -  StaticConfigController::PROVIDER_JSON = @tempfile.path +  if config == 'provider' +    StaticConfigController::PROVIDER_JSON = @tempfile.path +  else +    @orig_config ||= APP_CONFIG.dup +    APP_CONFIG[:config_file_paths].merge! "#{config}-service" => @tempfile.path +  end  end -# use with @config tag so the config changes are reverted after the scenario +# use with @config  Given /^"([^"]*)" is (enabled|disabled|"[^"]") in the config$/ do |key, value| +  @orig_config ||= APP_CONFIG.dup    value = case value            when 'disabled' then false            when 'enabled' then true @@ -14,3 +22,7 @@ Given /^"([^"]*)" is (enabled|disabled|"[^"]") in the config$/ do |key, value|            end    APP_CONFIG.merge! key => value  end + +Then /^the response should be that config$/ do +  assert_equal @dummy_config, last_response.body +end diff --git a/features/support/hooks.rb b/features/support/hooks.rb index f2e3b41..256e5d8 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -5,10 +5,8 @@ After '@tempfile' do    end  end -Around '@config' do |scenario, block| -  old_config = APP_CONFIG.dup -  block.call -  APP_CONFIG.replace old_config +After '@config' do |scenario, block| +  APP_CONFIG.replace @orig_config if @orig_config  end  # store end of server log for failing scenarios diff --git a/features/unauthenticated.feature b/features/unauthenticated.feature index 870adb1..aea7117 100644 --- a/features/unauthenticated.feature +++ b/features/unauthenticated.feature @@ -10,22 +10,10 @@ Feature: Unauthenticated API endpoints    @tempfile    Scenario: Fetch provider config -    Given the provider config is: -      """ -      {"config": "me"} -      """ +    Given there is a config for the provider      When I send a GET request to "/provider.json"      Then the response status should be "200" -    And the response should be: -      """ -      {"config": "me"} -      """ - -  @config -  Scenario: Fetch configs when anonymous certs are allowed -    Given "allow_anonymous_certs" is enabled in the config -    When I send a GET request to "/1/configs.json" -    Then the response status should be "200" +    And the response should be that config    Scenario: Authentication required response      When I send a GET request to "/1/configs" @@ -38,5 +26,6 @@ Feature: Unauthenticated API endpoints      When I send requests to these endpoints:        |  GET   | /1/configs                |        |  GET   | /1/configs/config_id.json | +      |  GET   | /1/service                |        | DELETE | /1/logout                 |      Then they should require authentication | 
