add test and docs for 401 Unauthorized
This commit is contained in:
parent
c631ecdc76
commit
797eada658
|
@ -65,6 +65,9 @@ All defined routes in the specification are appended to this url. To access all
|
|||
}, // etc
|
||||
]
|
||||
```
|
||||
|
||||
##### 401 Unauthorized
|
||||
No valid authentication credentials supplied.
|
||||
</details>
|
||||
|
||||
|
||||
|
@ -92,6 +95,9 @@ All defined routes in the specification are appended to this url. To access all
|
|||
##### 400 Bad Request
|
||||
Invalid ID supplied.
|
||||
|
||||
##### 401 Unauthorized
|
||||
No valid authentication credentials supplied.
|
||||
|
||||
##### 404 Not Found
|
||||
Note not found.
|
||||
</details>
|
||||
|
@ -117,6 +123,9 @@ Note not found.
|
|||
##### 400 Bad Request
|
||||
Invalid ID supplied.
|
||||
|
||||
##### 401 Unauthorized
|
||||
No valid authentication credentials supplied.
|
||||
|
||||
##### 507 Insufficient Storage
|
||||
Not enough free storage for saving the note's content.
|
||||
</details>
|
||||
|
@ -138,6 +147,9 @@ Not enough free storage for saving the note's content.
|
|||
##### 400 Bad Request
|
||||
Invalid ID supplied.
|
||||
|
||||
##### 401 Unauthorized
|
||||
No valid authentication credentials supplied.
|
||||
|
||||
##### 404 Not Found
|
||||
Note not found.
|
||||
|
||||
|
@ -161,6 +173,9 @@ Note is deleted.
|
|||
##### 400 Bad Request
|
||||
Invalid ID supplied.
|
||||
|
||||
##### 401 Unauthorized
|
||||
No valid authentication credentials supplied.
|
||||
|
||||
##### 404 Not Found
|
||||
Note not found.
|
||||
</details>
|
||||
|
|
|
@ -46,15 +46,17 @@ abstract class AbstractAPITest extends TestCase {
|
|||
$response->getHeaderLine('Content-Type'),
|
||||
$message.': Response content type'
|
||||
);
|
||||
$this->assertTrue(
|
||||
$response->hasHeader('X-Notes-API-Versions'),
|
||||
$message.': Response has Notes-API-Versions header'
|
||||
);
|
||||
$this->assertContains(
|
||||
$this->apiVersion,
|
||||
explode(', ', $response->getHeaderLine('X-Notes-API-Versions')),
|
||||
$message.': Response Notes-API-Versions header'
|
||||
);
|
||||
if ($statusExp !== 401) {
|
||||
$this->assertTrue(
|
||||
$response->hasHeader('X-Notes-API-Versions'),
|
||||
$message.': Response has Notes-API-Versions header'
|
||||
);
|
||||
$this->assertContains(
|
||||
$this->apiVersion,
|
||||
explode(', ', $response->getHeaderLine('X-Notes-API-Versions')),
|
||||
$message.': Response Notes-API-Versions header'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkGetReferenceNotes(
|
||||
|
|
|
@ -238,5 +238,9 @@ abstract class CommonAPITest extends AbstractAPITest {
|
|||
$this->assertEquals(507, $response2->getStatusCode());
|
||||
}
|
||||
|
||||
// TODO Test settings (switch to another notes folder)
|
||||
public function testUnauthorized() {
|
||||
$auth = ['test', 'wrongpassword'];
|
||||
$response = $this->http->request('GET', 'notes', [ 'auth' => $auth ]);
|
||||
$this->checkResponse($response, 'Get existing notes', 401);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue