Api >

Service Portal REST API

POST creates Standard Device with required and default attributes
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/devices/standard/123456789abc
with following body:
{
  "href": "/api/customers/K0002/devices/standard/123456789abc"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/standard/123456789abc
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/devices/standard/123456789abc",
  "links": [{
    "rel": "customer",
    "href": "/api/customers/K0002"
  }, {
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/1.0"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/1"
  }, {
    "rel": "activation",
    "href": "/api/customers/K0002/devices/standard/123456789abc/activate"
  }, {
    "rel": "siteOptions",
    "href": "/api/customers/K0002/devices/standard/123456789abc/site-options"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "ringtoneExternal",
    "value": 1
  }, {
    "name": "ringtoneInternal",
    "value": null
  }, {
    "name": "groupQueueSkillRingtone",
    "value": null
  }, {
    "name": "active",
    "value": true
  }, {
    "name": "useSiteOptionsFromSite",
    "value": true
  }, {
    "name": "webguiHttpsonly",
    "value": false
  }]
}
POST creates Standard Device with all possible attributes
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a site with ID a062000000HbAsd
and there is firmware with name 01.49
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.49"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "ringtoneInternal",
    "value": 5
  }, {
    "name": "ringtoneExternal",
    "value": 4
  }, {
    "name": "groupQueueSkillRingtone",
    "value": 4
  }, {
    "name": "webguiHttpsonly",
    "value": true
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/devices/standard/123456789abc
with following body:
{
  "href": "/api/customers/K0002/devices/standard/123456789abc"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/standard/123456789abc
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/devices/standard/123456789abc",
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.49"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "ringtoneInternal",
    "value": 5
  }, {
    "name": "ringtoneExternal",
    "value": 4
  }, {
    "name": "groupQueueSkillRingtone",
    "value": 4
  }, {
    "name": "webguiHttpsonly",
    "value": true
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }]
}
Cannot create Device if it will break Customer's Contract constraints
Given I am authenticated as Admin
and there is another customer K0003
and there is a Standard Device Type with name standard
my Contract does not allow me to add more Devices
and there is a site with ID a062000000HbAsd
When I send /api/customers/K0003/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0003/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Customer contract type does not allow to add more Devices"
  }]
}
Cannot create Standard Device with rejected ringtoneExternal
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a site with ID a062000000HbAsd
and there is firmware with name 01.49
and External Ringtones maximum numbers is set to 0
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.49"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "ringtoneExternal",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Field not allowed for device type or selected firmware",
    "path": "ringtoneExternal"
  }]
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/standard/123456789abc
Then I should receive HTTP/1.1 404 Not Found
Cannot create Standard Device with rejected ringtoneInternal
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a site with ID a062000000HbAsd
and there is firmware with name 01.49
and Internal Ringtone maximum numbers is set to 0
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.49"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "ringtoneInternal",
    "value": 5
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Field not allowed for device type or selected firmware",
    "path": "ringtoneInternal"
  }]
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/standard/123456789abc
Then I should receive HTTP/1.1 404 Not Found
Cannot create Standard Device with rejected groupQueueSkillRingtone
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a site with ID a062000000HbAsd
and there is firmware with name 01.49
and Group/Queue/Skill Ringtone maximum numbers is set to 0
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.49"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "groupQueueSkillRingtone",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "Field not allowed for device type or selected firmware",
    "path": "groupQueueSkillRingtone",
    "value": null
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/standard/123456789abc
Then I should receive HTTP/1.1 404 Not Found
Cannot create Standard Device with invalid ringtoneExternal value
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a site with ID a062000000HbAsd
and there is firmware with name 01.49
and External Ringtone maximum numbers is set to 5
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.49"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "ringtoneExternal",
    "value": 55
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Invalid value for Ringtone. Allowed values are 0-5",
    "path": "ringtoneExternal"
  }]
}
Cannot create Standard Device with invalid ringtoneInternal value
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a site with ID a062000000HbAsd
and there is firmware with name 01.49
and Internal Ringtone maximum numbers is set to 5
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.49"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "ringtoneInternal",
    "value": 55
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Invalid value for Ringtone. Allowed values are 0-5",
    "path": "ringtoneInternal"
  }]
}
Cannot create Standard Device with invalid groupQueueSkillRingtone value
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a site with ID a062000000HbAsd
and there is firmware with name 01.49
and Internal Ringtone maximum numbers is set to 5
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.49"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }, {
    "name": "groupQueueSkillRingtone",
    "value": 55
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "Invalid value for Ringtone. Allowed values are 0-5",
    "path": "groupQueueSkillRingtone",
    "value": null
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST creates Standard Device with preferred Firmware
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and with preferred firmware with name 10.45
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/devices/standard/123456789abc
with following body:
{
  "href": "/api/customers/K0002/devices/standard/123456789abc"
}
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/standard/123456789abc
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "href": "/api/customers/K0002/devices/standard/123456789abc",
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/10.45"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Admin cannot use site from another Customer when creating Standard Device
Given I am authenticated as admin
and there is a Standard Device Type with name standard
and there is a site with ID anotherSite for customer K0003
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/anotherSite"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Site not allowed",
    "detailMessage": "Site [anotherSite] is not reachable for customer [K0002]",
    "path": "site"
  }]
}
Cannot create Standard Device with duplicated ID
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "MAC number not unique",
    "path": "uniqueIdentifier"
  }]
}
Cannot create Standard Device with empty ID
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": ""
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "MAC number not defined",
    "path": "uniqueIdentifier"
  }]
}
Cannot create Standard Device with invalid ID
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abcinvalid"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "MAC number not valid",
    "path": "uniqueIdentifier"
  }]
}
Create Standard Device if firmware cannot be accessed
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a 01.34-beta firmware version
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.34-beta"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body:
{
  "title": "Access forbidden",
  "detail": "Access denied to [Firmware] with id [01.34-beta]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Create Standard Device if firmware cannot be accessed
Given I am authenticated as System Integrator S0002
and there is a Standard Device Type with name standard
and there is a 01.34-beta firmware version
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.34-beta"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body:
{
  "title": "Access forbidden",
  "detail": "Access denied to [Firmware] with id [01.34-beta]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Create Standard Device if firmware cannot be accessed
Given I am authenticated as Operator C0002
and there is a Standard Device Type with name standard
and there is a 01.34-beta firmware version
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.34-beta"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body:
{
  "title": "Access forbidden",
  "detail": "Access denied to [Firmware] with id [01.34-beta]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Create Standard Device if firmware cannot be accessed
Given I am authenticated as Admin
and there is a Standard Device Type with name standard
and there is a 01.34-beta firmware version
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.34-beta"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created
with following body:
{}
Create Standard Device if firmware can be accessed
Given I am authenticated as customer K0002
and there is a Standard Device Type with name standard
and there is a 01.34 firmware version
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.34"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created
with following body:
{}
Create Standard Device if firmware can be accessed
Given I am authenticated as System Integrator S0002
and there is a Standard Device Type with name standard
and there is a 01.34 firmware version
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.34"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created
with following body:
{}
Create Standard Device if firmware can be accessed
Given I am authenticated as Operator C0002
and there is a Standard Device Type with name standard
and there is a 01.34 firmware version
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.34"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created
with following body:
{}
Create Standard Device if firmware can be accessed
Given I am authenticated as Admin
and there is a Standard Device Type with name standard
and there is a 01.34 firmware version
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.34"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 201 Created
with following body:
{}
Cannot create Standard Device if firmware belongs to other Device Type
Given I am authenticated as admin K0002
and there is a Standard Device Type with name standard
and there is another Standard Device Type with name otherStandard
which has a firmware version 01.34-beta
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/otherStandard/firmwares/01.34-beta"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Firmware is invalid for selected device type",
    "detailMessage": "Provided firmware with releaseVersion 01.34-beta is invalid for device with type standard",
    "path": "firmware"
  }]
}
Cannot create Standard Device with missing firmware version
Given I am authenticated as K0002
and there is a Standard Device Type with name standard
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/standard/firmwares/01.23-missing"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "title": "Firmware not found",
  "detail": "Firmware with releaseVersion 01.23-missing not found",
  "described_by": "http://api.nfon.net/probs/firmware-not-found"
}
Cannot create Device with device type not allowed for Customer
Given I am authenticated as customer K0002
and there is a beta device type
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/beta"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body:
{
  "title": "Access forbidden",
  "detail": "Access denied to [DeviceType] with id [beta]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Cannot create Device with not existing Device Type
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/not-existing"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "title": "Device Type not found",
  "detail": "Device Type with name not-existing not found",
  "described_by": "http://api.nfon.net/probs/device-type-not-found"
}
Cannot create Device with invalid Device Type
Given I am authenticated as customer K0002
and there is a Standard Device Type with name base
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/base"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Cannot create Standard Device with type that is not Standard category",
    "path": "deviceType",
    "value": "/api/customers/K0002/device-types/base"
  }]
}
Cannot create Device with not existing Site
Given I am authenticated as customer K0002
and there is a Device Type device type with name standard
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/not-existing"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "detail": "Site [not-existing] not found for Customer [K0002]",
  "described_by": "http://api.nfon.net/probs/site-not-found"
}
Cannot create Device with Site that belongs to another Customer
Given I am authenticated as customer K0002
and there is a Device Type device type with name standard
and there is a site with ID anotherSite for customer K0003
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/anotherSite"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
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"
}
Cannot create Device with Site that belongs to another Customer
Given I am authenticated as admin
and there is a Device Type device type with name standard
and there is a site with ID anotherSite for customer K0003
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }, {
    "rel": "site",
    "href": "/api/customers/K0003/sites/anotherSite"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body:
{
  "errors": [{
    "message": "Site not allowed",
    "detailMessage": "Site [anotherSite] is not reachable for customer [K0002]",
    "path": "site"
  }]
}
Admin Cannot create Device with missing Customer
Given I am authenticated as Admin
and there is a Device Type device type with name standard
When I send /api/customers/K0404/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "title": "Customer not found",
  "detail": "Customer with identifier K0404 has not been found",
  "described_by": "http://api.nfon.net/probs/customer-not-found"
}
Cannot create Standard Device for another Customer
Given I am authenticated as K0003
and there is a Standard Device Type with name standard
When I send /api/customers/K0002/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
Then I should get HTTP/1.1 403 Forbidden
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0002]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
System Integrator cannot create Standard Device for Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0003/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
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 Standard Device for Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/devices/standard with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0003/device-types/standard"
  }],
  "data": [{
    "name": "uniqueIdentifier",
    "value": "123456789abc"
  }]
}
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"
}