Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
Jersey Jwt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yvan Peter
Jersey Jwt
Commits
9b84b008
Commit
9b84b008
authored
3 years ago
by
Yvan Peter
Browse files
Options
Downloads
Patches
Plain Diff
récupération dernières modifications
parent
03251600
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pom.xml
+25
-1
25 additions, 1 deletion
pom.xml
src/main/java/fr/ulille/iut/Main.java
+29
-0
29 additions, 0 deletions
src/main/java/fr/ulille/iut/Main.java
src/test/java/fr/ulille/iut/api/AuthRessourceTest.java
+49
-0
49 additions, 0 deletions
src/test/java/fr/ulille/iut/api/AuthRessourceTest.java
with
103 additions
and
1 deletion
pom.xml
+
25
−
1
View file @
9b84b008
...
@@ -48,12 +48,36 @@
...
@@ -48,12 +48,36 @@
<groupId>
org.glassfish.jersey.inject
</groupId>
<groupId>
org.glassfish.jersey.inject
</groupId>
<artifactId>
jersey-hk2
</artifactId>
<artifactId>
jersey-hk2
</artifactId>
</dependency>
</dependency>
<!-- Ajout pour utiliser le serveur HTTP Grizzly2 -->
<dependency>
<groupId>
org.glassfish.jersey.containers
</groupId>
<artifactId>
jersey-container-grizzly2-http
</artifactId>
<version>
2.27
</version>
</dependency>
<!-- Ajout pour pouvoir tester dans un container Jetty -->
<!-- <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.12.v20180830</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>2.27</version>
</dependency> -->
<!-- uncomment this to get JSON support -->
<!-- uncomment this to get JSON support -->
<dependency>
<dependency>
<groupId>
org.glassfish.jersey.media
</groupId>
<groupId>
org.glassfish.jersey.media
</groupId>
<artifactId>
jersey-media-json-binding
</artifactId>
<artifactId>
jersey-media-json-binding
</artifactId>
</dependency>
</dependency>
<!-- -->
<!-- -->
<!-- Ajout de la dépendance à JUnit -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
<!-- Ajout de la dépendance à jjwt, API java de Json Web Token -->
<!-- Ajout de la dépendance à jjwt, API java de Json Web Token -->
<dependency>
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<groupId>
io.jsonwebtoken
</groupId>
...
@@ -89,7 +113,7 @@
...
@@ -89,7 +113,7 @@
</dependencies>
</dependencies>
<properties>
<properties>
<jersey.version>
2.2
6
</jersey.version>
<jersey.version>
2.2
7
</jersey.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
</properties>
</project>
</project>
This diff is collapsed.
Click to expand it.
src/main/java/fr/ulille/iut/Main.java
0 → 100644
+
29
−
0
View file @
9b84b008
package
fr.ulille.iut
;
import
java.io.IOException
;
import
java.net.URI
;
import
javax.ws.rs.core.UriBuilder
;
import
org.glassfish.grizzly.http.server.HttpServer
;
import
org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory
;
public
class
Main
{
public
static
final
String
BASE_URI
=
"http://localhost:8080/app/"
;
static
HttpServer
startServer
()
throws
IOException
{
URI
baseUri
=
UriBuilder
.
fromUri
(
"http://localhost/app"
).
port
(
8080
).
build
();
HttpServer
server
=
GrizzlyHttpServerFactory
.
createHttpServer
(
baseUri
,
new
EntryPoint
());
// start the server
server
.
start
();
return
server
;
}
}
This diff is collapsed.
Click to expand it.
src/test/java/fr/ulille/iut/api/AuthRessourceTest.java
0 → 100644
+
49
−
0
View file @
9b84b008
package
fr.ulille.iut
;
import
javax.ws.rs.client.Client
;
import
javax.ws.rs.client.ClientBuilder
;
import
javax.ws.rs.client.WebTarget
;
import
javax.ws.rs.client.Entity
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Form
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
AuthRessourceTest
{
private
HttpServer
server
;
private
WebTarget
target
;
private
final
String
authURL
=
"/api/v1/authenticate"
;
@Before
public
void
setUp
()
throws
Exception
{
// start the server
server
=
Main
.
startServer
();
// create the client
target
=
ClientBuilder
.
newClient
().
target
(
Main
.
BASE_URI
);
}
@After
public
void
tearDown
()
throws
Exception
{
server
.
stop
();
}
@Test
public
void
testAuthenticateGoodUser
()
{
Form
form
=
new
Form
();
form
.
param
(
"login"
,
"Yvan"
);
form
.
param
(
"passwd"
,
"GoodPass"
);
Entity
<
Form
>
formEntity
=
Entity
.
entity
(
form
,
MediaType
.
APPLICATION_FORM_URLENCODED_TYPE
);
Response
response
=
target
.
path
(
authURL
).
request
().
post
(
formEntity
);
assertEquals
(
response
.
getStatus
(),
200
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment