Api >

Service Portal REST API

POST creates a License for given Base Device
Given I am authenticated as K0002
and there is a Base Device of category Kirk with MAC ABCDEF012345
and the next available License Key id is 10 and Port Type IPEI
When I send /api/customers/K0002/devices/base/ABCDEF012345/license-keys as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "licenseKey",
    "value": "A License Key"
  }, {
    "name": "licenseType",
    "value": "A License Type"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/devices/base/ABCDEF012345/license-keys/10 and following body:
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345/license-keys/10"
}
And the license with id 10 should have:
POST does not create License if base is not of Kirk type
Given I am authenticated as K0002
and there is a Base Device of category NotAKirk with MAC ABCDEF012345 and and Port Type PORT
When I send /api/customers/K0002/devices/base/ABCDEF012345/license-keys as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "licenseKey",
    "value": "A License Key"
  }, {
    "name": "licenseType",
    "value": "A License Type"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Licenses are only available for Kirk bases"
  }]
}
POST does not create License if licenseKey is empty
Given I am authenticated as K0002
and there is a Base Device of category Kirk with MAC ABCDEF012345 and Port Type IPEI
When I send /api/customers/K0002/devices/base/ABCDEF012345/license-keys as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "licenseKey",
    "value": ""
  }, {
    "name": "licenseType",
    "value": "A License Type"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "License Key has to be provided",
    "path": "licenseKey"
  }]
}
Cannot create Licence for missing Customer
Given I am authenticated as Admin
When I send /api/customers/K0404/devices/base/ABCDEF012345/license-keys as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "licenseKey",
    "value": "A License Key"
  }, {
    "name": "licenseType",
    "value": "A License Type"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "described_by": "http://api.nfon.net/probs/customer-not-found",
  "title": "Customer not found",
  "detail": "Customer with identifier K0404 has not been found"
}
POST fails meaningfully if requested Base Device does not exist
Given I am authenticated as K0002
And there is no Base Device with id ABCDEF012345
When I send /api/customers/K0002/devices/base/ABCDEF012345/license-keys as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "licenseKey",
    "value": "A License Key"
  }, {
    "name": "licenseType",
    "value": "A License Type"
  }]
}
Then I should receive HTTP/1.1 404 Not Found with following body:
{
  "title": "Device not found",
  "detail": "Device with unique identifier ABCDEF012345 has not been found",
  "described_by": "http://api.nfon.net/probs/device-not-found"
}
Customer cannot create Licence for other Customer
Given I am authenticated as K0003
and there is a Base Device of category Kirk with MAC ABCDEF012345
and the next available License Key id is 10 and Port Type IPEI
When I send /api/customers/K0002/devices/base/ABCDEF012345/license-keys as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "licenseKey",
    "value": "A License Key"
  }, {
    "name": "licenseType",
    "value": "A License Type"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden with following body:
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0002]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
System Integrator cannot create Licence for Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/devices/base/ABCDEF012345/license-keys as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "licenseKey",
    "value": "A License Key"
  }, {
    "name": "licenseType",
    "value": "A License Type"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Operator cannot create Licence for Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/devices/base/ABCDEF012345/license-keys as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "licenseKey",
    "value": "A License Key"
  }, {
    "name": "licenseType",
    "value": "A License Type"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}