Skip to content

Commit

Permalink
Removed mocks of JwtDecoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc3092 committed Jan 9, 2025
1 parent 2a285a9 commit ce5b7d7
Show file tree
Hide file tree
Showing 29 changed files with 91 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package no.nav.registre.testnorge.arbeidsforholdservice;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
Expand All @@ -13,12 +10,7 @@
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
@SuppressWarnings("unused")
private JwtDecoder jwtDecoder;

@Test
@DisplayName("Application context should load")
void load_app_context() {
assertThat(true).isTrue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,22 @@
import no.nav.testnav.libs.securitycore.domain.AccessToken;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.junit.jupiter.api.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;

import java.io.IOException;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@Tag("integration")
class BrukerServiceIntegrationTest {

private static final String PID = "01810048413";
private static final String ORGNUMMER = "811306312";
public static MockWebServer mockBackEnd;
@MockBean
JwtDecoder jwtDecoder;

private ObjectMapper objectMapper;
private WebClient webClient;
Expand Down Expand Up @@ -65,7 +58,7 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws
.setBody(objectMapper.writeValueAsString(new AccessToken("test"))));

var token = tokendingsClient.generateToken("dev-gcp:dolly:testnav-bruker-service", PID).block();

assertThat(token).isNotNull();

// Create user
var expected = new BrukerDTO(null, "username", ORGNUMMER, null, null);
Expand All @@ -83,7 +76,8 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws
.bodyToMono(BrukerDTO.class)
.block();

Assertions.assertThat(bruker)
assertThat(bruker)
.isNotNull()
.usingRecursiveComparison()
.comparingOnlyFields("brukernavn", "organisasjonsnummer")
.isEqualTo(expected);
Expand Down Expand Up @@ -132,7 +126,8 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws
.bodyToMono(BrukerDTO.class)
.block();

Assertions.assertThat(updatedUser.brukernavn()).isEqualTo("new-username");
assertThat(updatedUser).isNotNull();
assertThat(updatedUser.brukernavn()).isEqualTo("new-username");

mockBackEnd.enqueue(
new MockResponse().setResponseCode(200)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
public class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;
class ApplicationContextTest {

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@ActiveProfiles("test")
@SpringBootTest
public class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;
class ApplicationContextTest {

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@ActiveProfiles("test")
@SpringBootTest
public class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;
class ApplicationContextTest {

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.test.context.ActiveProfiles;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@ActiveProfiles("test")
class ApplicationContextTest {

@MockBean
public JwtDecoder jwtDecoder;

@Test
@SuppressWarnings("java:S2699")
void load_app_context() {
assertThat(true).isTrue();
}

}
Loading

0 comments on commit ce5b7d7

Please sign in to comment.