mirror of
https://github.com/fabioformosa/quartz-manager.git
synced 2025-12-24 19:43:14 +09:00
#78 fixed a smell
This commit is contained in:
@@ -21,7 +21,7 @@ export class UserService {
|
||||
|
||||
refreshToken() {
|
||||
this.apiService.get(this.config.refresh_token_url).subscribe(res => {
|
||||
if (res.access_token !== null) {
|
||||
if (res.accessToken !== null) {
|
||||
return this.getUserInfo().toPromise()
|
||||
.then(user => {
|
||||
this.currentUser = user;
|
||||
|
||||
@@ -1,32 +1,19 @@
|
||||
package it.fabioformosa.quartzmanager.api.security.models;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserTokenState {
|
||||
private String access_token;
|
||||
private Long expires_in_sec;
|
||||
private String accessToken;
|
||||
private Long expiresInSec;
|
||||
|
||||
public UserTokenState() {
|
||||
this.access_token = null;
|
||||
this.expires_in_sec = null;
|
||||
public UserTokenState(String accessToken, long expiresInSec) {
|
||||
this.accessToken = accessToken;
|
||||
this.expiresInSec = expiresInSec;
|
||||
}
|
||||
|
||||
public UserTokenState(String access_token, long expires_in_sec) {
|
||||
this.access_token = access_token;
|
||||
this.expires_in_sec = expires_in_sec;
|
||||
}
|
||||
|
||||
public String getAccess_token() {
|
||||
return access_token;
|
||||
}
|
||||
|
||||
public Long getExpires_in_sec() {
|
||||
return expires_in_sec;
|
||||
}
|
||||
|
||||
public void setAccess_token(String access_token) {
|
||||
this.access_token = access_token;
|
||||
}
|
||||
|
||||
public void setExpires_in_sec(Long expires_in_sec) {
|
||||
this.expires_in_sec = expires_in_sec;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class SecurityLoginViaCookieTest extends AbstractSecurityLoginTest {
|
||||
void givenAnAnonymousUser_whenTheLoginIsSubmitted_thenShouldReturn2xx() {
|
||||
ResponseEntity<UserTokenState> responseEntity = doLogin();
|
||||
Assertions.assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Assertions.assertThat(responseEntity.getBody().getAccess_token()).isNotEmpty();
|
||||
Assertions.assertThat(responseEntity.getBody().getExpires_in_sec()).isNotNull().isPositive();
|
||||
Assertions.assertThat(responseEntity.getBody().getAccessToken()).isNotEmpty();
|
||||
Assertions.assertThat(responseEntity.getBody().getExpiresInSec()).isNotNull().isPositive();
|
||||
Assertions.assertThat(responseEntity.getHeaders().get("set-cookie")).hasSizeGreaterThan(0);
|
||||
Assertions.assertThat(responseEntity.getHeaders().get("set-cookie").get(0)).startsWith("AUTH-TOKEN");
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ public class SecurityLoginViaDefaultStrategyTest extends AbstractSecurityLoginTe
|
||||
void givenAnAnonymousUser_whenTheLoginIsSubmitted_thenShouldReturn2xx() {
|
||||
ResponseEntity<UserTokenState> responseEntity = doLogin();
|
||||
Assertions.assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Assertions.assertThat(responseEntity.getBody().getAccess_token()).isNotEmpty();
|
||||
Assertions.assertThat(responseEntity.getBody().getExpires_in_sec()).isNotNull().isPositive();
|
||||
Assertions.assertThat(responseEntity.getBody().getAccessToken()).isNotEmpty();
|
||||
Assertions.assertThat(responseEntity.getBody().getExpiresInSec()).isNotNull().isPositive();
|
||||
Assertions.assertThat(responseEntity.getHeaders().get("set-cookie")).isNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ public class SecurityLoginViaHeaderAndLoginFilterTest extends AbstractSecurityLo
|
||||
void givenAnAnonymousUser_whenTheLoginIsSubmitted_thenShouldReturn2xx() {
|
||||
ResponseEntity<UserTokenState> responseEntity = doLogin();
|
||||
Assertions.assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Assertions.assertThat(responseEntity.getBody().getAccess_token()).isNotEmpty();
|
||||
Assertions.assertThat(responseEntity.getBody().getExpires_in_sec()).isNotNull().isPositive();
|
||||
Assertions.assertThat(responseEntity.getBody().getAccessToken()).isNotEmpty();
|
||||
Assertions.assertThat(responseEntity.getBody().getExpiresInSec()).isNotNull().isPositive();
|
||||
Assertions.assertThat(responseEntity.getHeaders().get("set-cookie")).isNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ public class SecurityLoginViaHeaderTest extends AbstractSecurityLoginTest {
|
||||
void givenAnAnonymousUser_whenTheLoginIsSubmitted_thenShouldReturn2xx() {
|
||||
ResponseEntity<UserTokenState> responseEntity = doLogin();
|
||||
Assertions.assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Assertions.assertThat(responseEntity.getBody().getAccess_token()).isNotEmpty();
|
||||
Assertions.assertThat(responseEntity.getBody().getExpires_in_sec()).isNotNull().isPositive();
|
||||
Assertions.assertThat(responseEntity.getBody().getAccessToken()).isNotEmpty();
|
||||
Assertions.assertThat(responseEntity.getBody().getExpiresInSec()).isNotNull().isPositive();
|
||||
Assertions.assertThat(responseEntity.getHeaders().get("set-cookie")).isNull();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user