Search in sources :

Example 1 with AuthContext

use of no.nav.common.auth.context.AuthContext in project veilarbportefolje by navikt.

the class EnhetControllerTest method skal_ikke_hente_noe_hvis_mangler_tilgang.

@Test(expected = ResponseStatusException.class)
public void skal_ikke_hente_noe_hvis_mangler_tilgang() {
    when(modiaPep.harVeilederTilgangTilModia(any())).thenReturn(false);
    authContextHolder.withContext(new AuthContext(UserRole.INTERN, generateMockJWT()), () -> enhetController.hentPortefoljeForEnhet("0001", null, 20, "ikke_satt", "ikke_satt", new Filtervalg()));
}
Also used : Filtervalg(no.nav.pto.veilarbportefolje.domene.Filtervalg) AuthContext(no.nav.common.auth.context.AuthContext) Test(org.junit.Test)

Example 2 with AuthContext

use of no.nav.common.auth.context.AuthContext in project veilarbportefolje by navikt.

the class EnhetControllerTest method skal_hent_portefolje_fra_indeks_dersom_tilgang.

@Test
@SneakyThrows
public void skal_hent_portefolje_fra_indeks_dersom_tilgang() {
    when(modiaPep.harVeilederTilgangTilModia(anyString())).thenReturn(true);
    when(pep.harVeilederTilgangTilEnhet(any(NavIdent.class), any(EnhetId.class))).thenReturn(true);
    when(opensearchService.hentBrukere(any(), any(), any(), any(), any(), any(), any())).thenReturn(new BrukereMedAntall(0, Collections.emptyList()));
    authContextHolder.withContext(new AuthContext(UserRole.INTERN, generateMockJWT()), () -> enhetController.hentPortefoljeForEnhet("0001", 0, 0, "ikke_satt", "ikke_satt", new Filtervalg()));
    verify(opensearchService, times(1)).hentBrukere(any(), any(), any(), any(), any(), any(), any());
}
Also used : Filtervalg(no.nav.pto.veilarbportefolje.domene.Filtervalg) EnhetId(no.nav.common.types.identer.EnhetId) BrukereMedAntall(no.nav.pto.veilarbportefolje.domene.BrukereMedAntall) AuthContext(no.nav.common.auth.context.AuthContext) NavIdent(no.nav.common.types.identer.NavIdent) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 3 with AuthContext

use of no.nav.common.auth.context.AuthContext in project veilarbportefolje by navikt.

the class EnhetControllerTest method skal_hente_hele_portefolje_fra_indeks_dersom_man_mangle_fra.

@Test
public void skal_hente_hele_portefolje_fra_indeks_dersom_man_mangle_fra() {
    when(pep.harVeilederTilgangTilEnhet(any(), any())).thenReturn(true);
    when(modiaPep.harVeilederTilgangTilModia(any())).thenReturn(true);
    when(opensearchService.hentBrukere(any(), any(), any(), any(), any(), any(), any())).thenReturn(new BrukereMedAntall(0, Collections.emptyList()));
    authContextHolder.withContext(new AuthContext(UserRole.INTERN, generateMockJWT()), () -> enhetController.hentPortefoljeForEnhet("0001", null, 20, "ikke_satt", "ikke_satt", new Filtervalg()));
    verify(opensearchService, times(1)).hentBrukere(any(), any(), any(), any(), any(), isNull(), any());
}
Also used : Filtervalg(no.nav.pto.veilarbportefolje.domene.Filtervalg) BrukereMedAntall(no.nav.pto.veilarbportefolje.domene.BrukereMedAntall) AuthContext(no.nav.common.auth.context.AuthContext) Test(org.junit.Test)

Example 4 with AuthContext

use of no.nav.common.auth.context.AuthContext in project veilarbportefolje by navikt.

the class EnhetControllerTest method skal_hente_hele_portefolje_fra_indeks_dersom_man_mangle_antall.

@Test
public void skal_hente_hele_portefolje_fra_indeks_dersom_man_mangle_antall() {
    when(pep.harVeilederTilgangTilEnhet(any(), any())).thenReturn(true);
    when(modiaPep.harVeilederTilgangTilModia(any())).thenReturn(true);
    when(opensearchService.hentBrukere(any(), any(), any(), any(), any(), any(), any())).thenReturn(new BrukereMedAntall(0, Collections.emptyList()));
    authContextHolder.withContext(new AuthContext(UserRole.INTERN, generateMockJWT()), () -> enhetController.hentPortefoljeForEnhet("0001", 0, null, "ikke_satt", "ikke_satt", new Filtervalg()));
    verify(opensearchService, times(1)).hentBrukere(any(), any(), any(), any(), any(), any(), any());
}
Also used : Filtervalg(no.nav.pto.veilarbportefolje.domene.Filtervalg) BrukereMedAntall(no.nav.pto.veilarbportefolje.domene.BrukereMedAntall) AuthContext(no.nav.common.auth.context.AuthContext) Test(org.junit.Test)

Aggregations

AuthContext (no.nav.common.auth.context.AuthContext)4 Filtervalg (no.nav.pto.veilarbportefolje.domene.Filtervalg)4 Test (org.junit.Test)4 BrukereMedAntall (no.nav.pto.veilarbportefolje.domene.BrukereMedAntall)3 SneakyThrows (lombok.SneakyThrows)1 EnhetId (no.nav.common.types.identer.EnhetId)1 NavIdent (no.nav.common.types.identer.NavIdent)1