upgrade to quarkus 2.1.3
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -14,7 +14,7 @@
|
|||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
|
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
|
||||||
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
|
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
|
||||||
<quarkus.platform.version>2.0.0.Final</quarkus.platform.version>
|
<quarkus.platform.version>2.1.3.Final</quarkus.platform.version>
|
||||||
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
|
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class UserResource {
|
|||||||
@RolesAllowed({"USER", "ADMIN"})
|
@RolesAllowed({"USER", "ADMIN"})
|
||||||
public TemplateInstance getUser() {
|
public TemplateInstance getUser() {
|
||||||
TemplateInstance templateInstance = userTemplate
|
TemplateInstance templateInstance = userTemplate
|
||||||
.data("current_username", identity.getPrincipal().getName());
|
.data("current_user", User.find("username", identity.getPrincipal().getName()).singleResult());
|
||||||
|
|
||||||
if (identity.hasRole("ADMIN")) {
|
if (identity.hasRole("ADMIN")) {
|
||||||
templateInstance
|
templateInstance
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<a class="btn btn-outline-primary me-2" href="/user/logout">Logout</a>
|
<a class="btn btn-outline-primary me-2" href="/user/logout">Logout</a>
|
||||||
</nav>
|
</nav>
|
||||||
{#if error}<div class="alert alert-danger" role="alert">{error}</div>{/if}
|
{#if error??}<div class="alert alert-danger" role="alert">{error}</div>{/if}
|
||||||
{#if info}<div class="alert alert-primary" role="alert">{info}</div>{/if}
|
{#if info??}<div class="alert alert-primary" role="alert">{info}</div>{/if}
|
||||||
{#insert contents}No contents!{/}
|
{#insert contents}No contents!{/}
|
||||||
</div>
|
</div>
|
||||||
<script src="/webjars/popper.js/2.9.2/umd/popper.min.js"></script>
|
<script src="/webjars/popper.js/2.9.2/umd/popper.min.js"></script>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div class="modal fade" id="userModal{#if id}{id}{/if}" tabindex="-1" aria-labelledby="userModalLabel" aria-hidden="true">
|
<div class="modal fade" id="userModal{#if id??}{id}{/if}" tabindex="-1" aria-labelledby="userModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
@@ -6,22 +6,22 @@
|
|||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action="/user/{#if update}update{#else}new{/if}" method="POST" name="userForm" enctype="multipart/form-data">
|
<form action="/user/{#if update??}update{#else}new{/if}" method="POST" name="userForm" enctype="multipart/form-data">
|
||||||
<div class="modal-body row mb-3">
|
<div class="modal-body row mb-3">
|
||||||
<div class="align-items-center col-md-10 mx-auto col-lg-11">
|
<div class="align-items-center col-md-10 mx-auto col-lg-11">
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input type="text" name="username" class="form-control" id="name" placeholder="Benutzername" required
|
<input type="text" name="username" class="form-control" id="name" placeholder="Benutzername" required
|
||||||
{#if update}readonly value="{user.username}"{/if}>
|
{#if update??}readonly value="{user.username}"{/if}>
|
||||||
<label for="name">Benutzername</label>
|
<label for="name">Benutzername</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input type="password" name="password" class="form-control" id="pwd" placeholder="Password" required
|
<input type="password" name="password" class="form-control" id="pwd" placeholder="Password" required
|
||||||
{#if update}disabled value="xxxxx"{/if}>
|
{#if update??}disabled value="xxxxx"{/if}>
|
||||||
<label for="pwd">Passwort</label>
|
<label for="pwd">Passwort</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input type="password" name="passwordVerify" class="form-control" id="pwdv" placeholder="Passwort wiederholen" required
|
<input type="password" name="passwordVerify" class="form-control" id="pwdv" placeholder="Passwort wiederholen" required
|
||||||
{#if update}disabled value="xxxxx"{/if}>
|
{#if update??}disabled value="xxxxx"{/if}>
|
||||||
<label for="pwd">Passwort wiederholen</label>
|
<label for="pwd">Passwort wiederholen</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
@@ -34,9 +34,9 @@
|
|||||||
<label class="col-sm-3 col-form-label1" for="room">Raum</label>
|
<label class="col-sm-3 col-form-label1" for="room">Raum</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<select id="role" name="role" class="form-select" required {#if update}disabled{/if}>
|
<select id="role" name="role" class="form-select" required {#if update??}disabled{/if}>
|
||||||
<option {#if update and user.hasRoleUser}selected{/if}>USER</option>
|
<option {#if update?? and user.hasRoleUser}selected{/if}>USER</option>
|
||||||
<option {#if update and user.hasRoleAdmin}selected{/if}>ADMIN</option>
|
<option {#if update?? and user.hasRoleAdmin}selected{/if}>ADMIN</option>
|
||||||
</select>
|
</select>
|
||||||
<label class="col-sm-3 col-form-label1" for="role">Rolle</label>
|
<label class="col-sm-3 col-form-label1" for="role">Rolle</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
{#contents}
|
{#contents}
|
||||||
|
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<h2>Hallo {current_username}</h2>
|
<h2>Hallo {current_user.username}</h2>
|
||||||
{#if is_admin}
|
{#if is_admin??}
|
||||||
<table class="table table-striped table-bordered">
|
<table class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -34,12 +34,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-2" >
|
<div class="mt-2" >
|
||||||
{#if is_admin}
|
{#if is_admin??}
|
||||||
<a class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#userModal" role="button">neuer Benutzer</a>
|
<a class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#userModal" role="button">neuer Benutzer</a>
|
||||||
{/if}
|
{/if}
|
||||||
<a class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#passwordModal" role="button">Passwort ändern</a>
|
<a class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#passwordModal" role="button">Passwort ändern</a>
|
||||||
{#if is_admin}
|
{#if is_admin??}
|
||||||
{#include user-modal.html rooms=rooms}{/include}
|
{#include user-modal.html rooms=rooms user=current_user}{/include}
|
||||||
{/if}
|
{/if}
|
||||||
{#include password-modal.html}{/include}
|
{#include password-modal.html}{/include}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
43
src/test/java/de/mbremer/secutity/UserResourceTest.java
Normal file
43
src/test/java/de/mbremer/secutity/UserResourceTest.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package de.mbremer.secutity;
|
||||||
|
|
||||||
|
import io.quarkus.hibernate.orm.panache.PanacheQuery;
|
||||||
|
import io.quarkus.panache.mock.PanacheMock;
|
||||||
|
import io.quarkus.security.identity.SecurityIdentity;
|
||||||
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
import io.quarkus.test.junit.mockito.InjectMock;
|
||||||
|
import io.quarkus.test.security.TestSecurity;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
import static io.restassured.RestAssured.given;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@QuarkusTest
|
||||||
|
class UserResourceTest {
|
||||||
|
|
||||||
|
@InjectMock
|
||||||
|
SecurityIdentity identity;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestSecurity(authorizationEnabled = false)
|
||||||
|
void testUser() {
|
||||||
|
Principal principal = mock(Principal.class);
|
||||||
|
when(principal.getName()).thenReturn("user");
|
||||||
|
when(identity.getPrincipal()).thenReturn(principal);
|
||||||
|
|
||||||
|
PanacheMock.mock(User.class);
|
||||||
|
PanacheQuery panacheQuery = mock(PanacheQuery.class);
|
||||||
|
when(panacheQuery.singleResult()).thenReturn(new User());
|
||||||
|
when(User.find("username", "user")).thenReturn(panacheQuery);
|
||||||
|
|
||||||
|
given()
|
||||||
|
.when().get("/user")
|
||||||
|
.then()
|
||||||
|
.statusCode(200)
|
||||||
|
.body(containsString("Hallo"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user