Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Antonio Rueda
/
UJACoin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3e59c914
authored
Dec 25, 2020
by
Antonio Rueda
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Nuevo test para comprobar que un cliente no puede acceder a los datos
de otro
parent
a5f04382
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
2 deletions
src/test/java/es/ujaen/dae/ujacoin/controladoresREST/ControladorRESTTest.java
src/test/java/es/ujaen/dae/ujacoin/controladoresREST/ControladorRESTTest.java
View file @
3e59c914
...
...
@@ -83,7 +83,7 @@ public class ControladorRESTTest {
* test de alta y login de cliente
*/
@Test
public
void
testAltaY
LoginClienteCuenta
()
{
public
void
testAltaY
AccesoDatosCliente
()
{
DTOCliente
cliente
=
new
DTOCliente
(
"11995667D"
,
"Juan España España"
,
...
...
@@ -108,7 +108,7 @@ public class ControladorRESTTest {
.
getForEntity
(
"/clientes/{dni}"
,
DTOCliente
.
class
,
cliente
.
getDni
()
,
cliente
.
getClave
()
cliente
.
getDni
()
);
Assertions
.
assertThat
(
respuestaLogin
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
...
...
@@ -118,6 +118,57 @@ public class ControladorRESTTest {
}
/**
* test de alta e intento de acceso a datos de otro cliente
*/
@Test
public
void
testAltaYAccesoDatosClienteDiferente
()
{
DTOCliente
cliente
=
new
DTOCliente
(
"11995667D"
,
"Juan España España"
,
LocalDate
.
of
(
1990
,
11
,
1
),
"Cl La Luz, 13 - Jaén"
,
"988674533"
,
"jee@gmail.com"
,
"clave"
);
TestRestTemplate
restTemplate
=
new
TestRestTemplate
(
restTemplateBuilder
);
restTemplate
.
postForEntity
(
"/clientes"
,
cliente
,
DTOCuenta
.
class
);
// Crear segundo cliente
DTOCliente
cliente2
=
new
DTOCliente
(
"99207668E"
,
"Pedro Jaén, Jaén"
,
LocalDate
.
of
(
1992
,
1
,
2
),
"Cl La Paz, 20 - Jaén"
,
"670701570"
,
"pjj@gmail.com"
,
"clavezzz"
);
restTemplate
.
postForEntity
(
"/clientes"
,
cliente2
,
DTOCuenta
.
class
).
getBody
();
TestRestTemplate
restTemplateAutenticado
=
new
TestRestTemplate
(
restTemplateBuilder
.
basicAuthentication
(
cliente
.
getDni
(),
cliente
.
getClave
()));
// Acceso con credenciales del primer cliente a la información del segundo
ResponseEntity
<
DTOCliente
>
respuestaLogin
=
restTemplateAutenticado
.
getForEntity
(
"/clientes/{dni}"
,
DTOCliente
.
class
,
cliente2
.
getDni
()
);
Assertions
.
assertThat
(
respuestaLogin
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
FORBIDDEN
);
}
/**
* Creación de cuenta adicional
*/
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment