Skip to content

Commit

Permalink
Fix: Wonderwall
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsladek committed Nov 7, 2024
1 parent f72b140 commit 10db17b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import no.nav.foreldrepenger.vtp.testmodell.repo.BasisdataProvider;
import no.nav.foreldrepenger.vtp.testmodell.repo.TestscenarioBuilderRepository;
import no.nav.foreldrepenger.vtp.testmodell.repo.impl.BasisdataProviderFileImpl;
import no.nav.foreldrepenger.vtp.testmodell.repo.impl.TestscenarioRepositoryImpl;

/*
* Tjeneste for å sjekke om person har tilgang til en .
Expand All @@ -23,17 +27,17 @@
@Tag(name = "altinn-rettigheter")
@Path("/altinn-rettigheter-proxy")
public class AltinnRettigheterProxyMock {
protected static final Set<String> ALLE_VIRKSOMHETER = BasisdataProviderFileImpl.getInstance()
.getVirksomhetIndeks()
.getAlleVirksomheter()
.keySet();

@Context
private TestscenarioBuilderRepository scenarioRepository;

@GET
@Path("/ekstern/altinn/api/serviceowner/reportees")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Henter alle virksomheter.")
public Response hentTilgangerTilVirksomheter() {
return Response.ok().entity(mapToResponse()).build();
var alleOrgnr = scenarioRepository.hentAlleOrganisasjonsnummer();
return Response.ok().entity(mapToResponse(alleOrgnr)).build();
}

@GET
Expand All @@ -44,8 +48,8 @@ public Response hentIngenTilganger() {
return Response.ok().entity(List.of()).build();
}

private List<AltinnReportee> mapToResponse() {
return AltinnRettigheterProxyMock.ALLE_VIRKSOMHETER.stream().map(AltinnReportee::new).toList();
private List<AltinnReportee> mapToResponse(Set<String> alleOrgnr) {
return alleOrgnr.stream().map(AltinnReportee::new).toList();
}

@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class OrganisasjonIndeks {
Expand All @@ -15,4 +16,8 @@ public Optional<OrganisasjonModell> getModellForIdent(String orgnr) {
public void leggTil(List<OrganisasjonModell> modeller) {
modeller.forEach(o -> organisasjoner.put(o.orgnummer(), o));
}

public Set<String> hentAlleOrganisasjonsnummer() {
return organisasjoner.keySet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;
import java.util.Optional;
import java.util.Set;

import no.nav.foreldrepenger.vtp.testmodell.enheter.EnheterIndeks;
import no.nav.foreldrepenger.vtp.testmodell.identer.LokalIdentIndeks;
Expand Down Expand Up @@ -36,4 +37,6 @@ public interface TestscenarioBuilderRepository {

void indekserPersonopplysninger(Personopplysninger personopplysninger);

Set<String> hentAlleOrganisasjonsnummer();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

import no.nav.foreldrepenger.vtp.testmodell.enheter.EnheterIndeks;
import no.nav.foreldrepenger.vtp.testmodell.identer.LokalIdentIndeks;
Expand Down Expand Up @@ -82,4 +83,9 @@ public Boolean endreTestscenario(String id, Testscenario testscenario) {
public void indekserPersonopplysninger(Personopplysninger personopplysninger) {
delegate.indekserPersonopplysninger(personopplysninger);
}

@Override
public Set<String> hentAlleOrganisasjonsnummer() {
return delegate.hentAlleOrganisasjonsnummer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.Logger;
Expand Down Expand Up @@ -44,12 +45,15 @@ public Optional<OrganisasjonModell> getOrganisasjon(String orgnr) {
return organisasjonIndeks.getModellForIdent(orgnr);
}

@Override
public Set<String> hentAlleOrganisasjonsnummer() {
return organisasjonIndeks.hentAlleOrganisasjonsnummer();
}

protected TestscenarioBuilderRepositoryImpl(BasisdataProvider basisdata) {
this.basisdata = basisdata;
}


@Override
public Map<String, Testscenario> getTestscenarios() {
return scenarios;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public Response wellKnown(@SuppressWarnings("unused") @Context HttpServletReques
baseUrl + "/jwks",
baseUrl + "/access_token",
List.of("idporten-loa-high"),
List.of("nb")
);
List.of("nb"),
List.of("RS256"));
return Response.ok(wellKnownResponse).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public record WellKnownResponse(String issuer,
String jwks_uri,
String token_endpoint,
List<String> acr_values_supported,
List<String> ui_locales_supported) {
List<String> ui_locales_supported,
List<String> id_token_signing_alg_values_supported) {
}

0 comments on commit 10db17b

Please sign in to comment.