Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor API change and a test for the HTTP handler roles setup.
- Loading branch information
1 parent
bef1aec
commit 1e33584
Showing
6 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
rapidoid-integration-tests/src/test/java/org/rapidoid/http/HttpRolesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
package org.rapidoid.http; | |||
|
|||
/* | |||
* #%L | |||
* rapidoid-integration-tests | |||
* %% | |||
* Copyright (C) 2014 - 2016 Nikolche Mihajlovski and contributors | |||
* %% | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
* #L% | |||
*/ | |||
|
|||
import org.junit.Test; | |||
import org.rapidoid.annotation.Authors; | |||
import org.rapidoid.annotation.Since; | |||
import org.rapidoid.setup.On; | |||
|
|||
@Authors("Nikolche Mihajlovski") | |||
@Since("5.1.0") | |||
public class HttpRolesTest extends HttpTestCommons { | |||
|
|||
@Test | |||
public void testRoles() { | |||
On.defaults().roles("aa", "bb"); | |||
|
|||
On.get("/a").json(() -> "ok"); | |||
On.get("/ok").roles().json(() -> "ok"); | |||
|
|||
onlyGet("/a"); | |||
onlyGet("/ok"); | |||
} | |||
|
|||
} |
8 changes: 8 additions & 0 deletions
8
rapidoid-integration-tests/src/test/resources/test-results/HttpRolesTest/testRoles/GET_a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
HTTP/1.1 403 Forbidden | |||
Connection: keep-alive | |||
Server: Rapidoid | |||
Date: XXXXX GMT | |||
Content-Type: application/json; charset=utf-8 | |||
Content-Length: 85 | |||
|
|||
{"error":"The user doesn't have the required roles!","code":403,"status":"Forbidden"} |
8 changes: 8 additions & 0 deletions
8
rapidoid-integration-tests/src/test/resources/test-results/HttpRolesTest/testRoles/GET_ok
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
HTTP/1.1 200 OK | |||
Connection: keep-alive | |||
Server: Rapidoid | |||
Date: XXXXX GMT | |||
Content-Type: application/json; charset=utf-8 | |||
Content-Length: 4 | |||
|
|||
"ok" |