Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'mfl/master'

  • Loading branch information...
commit f5b6ae2a324137398c1694c8102dd145357899dd 2 parents 40c4733 + 0b5881e
@matthewfl matthewfl authored
View
82 features/api_keys.feature
@@ -6,30 +6,21 @@ Feature: API Keys
API keys are used to make authenticated requests by sending an HTTP Basic
Auth header, using the key as the username, with no password.
- Scenario: Create an API Key
+ Scenario: Create an API Key for a new marketplace
To obtain a key, one must be created. This is done through an
unauthenticated API request.
When I POST to /api_keys without my secret key
Then I should get a 201 Created status code
- And the response has this schema:
- """
- {
- "api_keys": {
- "type": "array",
- "minItems": 1,
- "maxItems": 1,
- "properties": {
- "href": { "type": "string" },
- "id": { "type": "string" },
- "secret": { "type": "string" },
- "links": { "type": "object" },
- "meta": { "type": "object" }
- }
- },
- "required": ["api_keys"]
- }
- """
+ And the response is valid according to the "api_keys" schema
+
+ Scenario: Create a new api key for a marketplace
+ To obtain a key, one must be created using the existing secret key
+ for a marketplace
+
+ When I POST to /api_keys
+ Then I should get a 201 Created status code
+ And the response is valid according to the "api_keys" schema
Scenario: Retrieve information about an existing API key
Right now, there's not a whole lot of extra information, but we support it
@@ -38,24 +29,7 @@ Feature: API Keys
Given I have created an API key
When I GET to /api_keys/:api_key giving the key
Then I should get a 200 OK status code
- And the response has this schema:
- """
- {
- "api_keys": {
- "type": "array",
- "minItems": 1,
- "maxItems": 1,
- "properties": {
- "href": { "type": "string" },
- "id": { "type": "string" },
- "secret": { "type": "string" },
- "links": { "type": "object" },
- "meta": { "type": "object" }
- }
- },
- "required": ["api_keys"]
- }
- """
+ And the response is valid according to the "api_keys" schema
Scenario: List all API keys
Customers can make as many keys as they'd like. Being able to see all of
@@ -64,39 +38,7 @@ Feature: API Keys
Given I have created more than one API keys
When I GET to /api_keys
Then I should get a 200 OK status code
- And the response has this schema:
- """
- {
- "api_keys": {
- "type": "array",
- "minItems": 1,
- "maxItems": 1,
- "properties": {
- "href": { "type": "string" },
- "id": { "type": "string" },
- "secret": { "type": "string" },
- "links": { "type": "object" },
- "meta": { "type": "object" }
- }
- },
- "properties": {
- "meta": {
- "type": "object",
- "properties": {
- "first": { "type": "string" },
- "href": { "type": "string" },
- "last": { "type": "string" },
- "limit": { "type": "integer" },
- "next": { "type": ["string", "null"] },
- "offset": { "type": "integer" },
- "previous": { "type": ["string", "null"] },
- "total": { "type": "integer" }
- }
- }
- },
- "required": ["api_keys"]
- }
- """
+ And the response is valid according to the "api_keys" schema
Scenario: Remove an API key
Sometimes, a customer just doesn't want an API key any more. Deleting that
View
13 features/debits.feature
@@ -212,3 +212,16 @@ Feature: Debit a card or bank account
"""
Then I should get a 201 Created status code
And the response is valid according to the "debits" schema
+
+ Scenario: Debit unassociated card
+ Given I have tokenized a card
+ When I POST to /cards/:card_id/debits with the body:
+ """
+ {
+ "debits": [{
+ "amount": 5000
+ }]
+ }
+ """
+ Then I should get a 201 Created status code
+ And the response is valid according to the "debits" schema
View
38 fixtures/_models/api_key.json
@@ -0,0 +1,38 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "pattern": "AK[a-zA-Z0-9]{16,32}"
+ },
+ "href": {
+ "type": "string",
+ "format": "uri"
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "secret": {
+ "type": "string",
+ "pattern": "ak-(test|prod)-[a-zA-Z0-9]{16,32}"
+ },
+ "meta": {
+ "type": "object"
+ },
+ "links": {
+ "type": "object",
+ "properties": {},
+ "additionalProperties": false
+ }
+ },
+ "required": [
+ "id",
+ "href",
+ "created_at",
+ "meta",
+ "links"
+ ],
+ "additionalProperties": false
+}
View
25 fixtures/api_keys.json
@@ -0,0 +1,25 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "links": {
+ "type": "object",
+ "properties": {},
+ "required": []
+ },
+ "meta": {
+ "type": "object"
+ },
+ "api_keys": {
+ "items": {
+ "$ref": "_models/api_key.json"
+ },
+ "type": "array",
+ "minItems": 1,
+ "uniqueItems": true
+ }
+ },
+ "required": [
+ "api_keys"
+ ]
+}
Please sign in to comment.
Something went wrong with that request. Please try again.