Api >

Service Portal REST API

Should update Announcement properties
Given I am authenticated as Customer K0002
and there is an Announcement with Id 15 and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav
and name announcement.mp3
and type GENERAL_ANNOUNCEMENT
When I send /api/customers/K0002/announcements/15 as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "name",
    "value": "name changed with api"
  }]
}
Then I should receive HTTP/1.1 204 No Content

Then when I am authenticated as Customer K0002
When I send /api/customers/K0002/announcements/15
Then I should receive HTTP/1.1 200 OK with following body:
{
  "href": "/api/customers/K0002/announcements/15",
  "links": [],
  "data": [{
    "name": "name",
    "value": "name changed with api"
  }, {
    "name": "type",
    "value": "GENERAL_ANNOUNCEMENT"
  }, {
    "name": "duration",
    "value": 8
  }]
}
Announcement name must be unique
Given I am authenticated as Customer K0002
and there is an Announcement with Id 15 and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav
and name announcement.mp3
and there is another Announcement with Id 20 and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement_2.mp3
and name announcement_2.mp3
When I send /api/customers/K0002/announcements/15 as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "name",
    "value": "announcement_2.mp3"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Announcement name must be unique",
    "path": "name",
    "value": "announcement_2.mp3"
  }]
}
Cannot update Announcement with empty name
Given I am authenticated as Customer K0002
and there is an Announcement with Id 15 and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav
and name announcement.mp3
When I send /api/customers/K0002/announcements/15 as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "name",
    "value": null
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "Announcement name is required",
    "path": "name",
    "value": null
  }]
}
Should update Announcement file
Given I am authenticated as Customer K0002
and there is an Announcement with Id 15 and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav
When I send /api/customers/K0002/announcements/15
with following multipart body:
Part Name: audiofile Content Type: audio/mpeg
classpath:net/nfon/portal/api/customer/announcement/announcement_2.mp3

Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "announcement_2.mp3"
  }]
}
then I should receive HTTP/1.1 204 No Content
Then when I am authenticated as Customer K0002
When I send /api/customers/K0002/announcements/15
Then I should receive HTTP/1.1 200 OK with following body:
{
  "href": "/api/customers/K0002/announcements/15",
  "links": [],
  "data": [{
    "name": "name",
    "value": "announcement_2.mp3"
  }, {
    "name": "type",
    "value": "GENERAL_ANNOUNCEMENT"
  }, {
    "name": "duration",
    "value": 9
  }]
}
Cannot update Announcement with non-audio file
Given I am authenticated as Customer K0002
and there is an Announcement with Id 15 and content from file ./src/test/resources/net/nfon/portal/api/customer/announcement/announcement.wav
When I send /api/customers/K0002/announcements/15
with following multipart body:
Part Name: audiofile Content Type: audio/mpeg
classpath:net/nfon/portal/api/customer/announcement/not_audio.gif

Part Name: body Content Type: application/json
{
  "data": [{
    "name": "name",
    "value": "not_audio.gif"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
with following body
{
  "errors": [{
    "message": "File 'not_audio.gif' is not a WAV/MP3 file.",
    "path": "audiofile"
  }]
}
PUT returns 404 if Customer is missing
Given I am authenticated as Admin
and there is no Customer K0404
When I send /api/customers/K0404/announcements/15 as application/json; charset=UTF-8
with following body:
{}
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"
}
PUT returns 404 if requested Announcement is missing
Given I am authenticated as Customer K0002
and there is no Announcement with Id 404
When I send /api/customers/K0002/announcements/404 as application/json; charset=UTF-8
with following body:
{}
Then I should receive HTTP/1.1 404 Not Found with following body:
{
  "title": "Announcement not found",
  "detail": "Announcement with id 404 has not been found",
  "described_by": "http://api.nfon.net/probs/announcement-not-found"
}
PUT returns 403 if requested Announcement belongs to another Customer
Given I am authenticated as K0003
and there is an Announcement with Id 15
When I send /api/customers/K0002/announcements/15 as application/json; charset=UTF-8
with following body:
{}
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 update Announcement of Customer, that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/announcements/15 as application/json; charset=UTF-8
with following body:
{}
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 update Announcement of Customer, that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/announcements/15 as application/json; charset=UTF-8
with following body:
{}
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"
}