diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index de3dd5fe4..95bc77e84 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -98,3 +98,23 @@ jobs: # tag_name: release/prod@${{ env.TAG }} # name: Release to prod # prerelease: false + + apply-apitoken-unleash: + name: Legger til ApiToken for Unleash + runs-on: ubuntu-latest + needs: [test-build-and-push] + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: deploy to dev + uses: nais/deploy/actions/deploy@v1 + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + CLUSTER: dev-gcp + RESOURCE: nais/unleash-apitoken-dev.yaml + - name: deploy to prod + uses: nais/deploy/actions/deploy@v1 + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + CLUSTER: prod-gcp + RESOURCE: nais/unleash-apitoken-prod.yaml diff --git a/nais/nais-dev-gcp.yaml b/nais/nais-dev-gcp.yaml index 0dc78f564..8ba62a8d8 100644 --- a/nais/nais-dev-gcp.yaml +++ b/nais/nais-dev-gcp.yaml @@ -17,6 +17,7 @@ spec: enabled: true envFrom: - secret: veilarbregistrering + - secret: veilarbregistrering-unleash-api-token image: {{image}} ingresses: - https://veilarbregistrering.intern.dev.nav.no @@ -65,6 +66,8 @@ spec: value: https://ereg-services-q1.dev-fss-pub.nais.io/ereg - name: SPRING_PROFILES_ACTIVE value: gcp + - name: UNLEASH_SERVER_API_URL + value: https://paw-unleash-api.nav.cloud.nais.io/api leaderElection: true kafka: pool: nav-dev @@ -137,6 +140,7 @@ spec: - host: norg2.dev-fss-pub.nais.io - host: oppgave-q1.dev-fss-pub.nais.io - host: ereg-services-q1.dev-fss-pub.nais.io + - host: paw-unleash-api.nav.cloud.nais.io rules: - application: aareg-services-nais-q1 namespace: arbeidsforhold diff --git a/nais/nais-prod-gcp.yaml b/nais/nais-prod-gcp.yaml index 01a0f4065..736ba0f48 100644 --- a/nais/nais-prod-gcp.yaml +++ b/nais/nais-prod-gcp.yaml @@ -17,6 +17,7 @@ spec: enabled: true envFrom: - secret: veilarbregistrering + - secret: veilarbregistrering-unleash-api-token image: {{image}} ingresses: - https://veilarbregistrering.intern.nav.no @@ -65,6 +66,8 @@ spec: value: https://ereg-services.prod-fss-pub.nais.io/ereg - name: SPRING_PROFILES_ACTIVE value: gcp + - name: UNLEASH_SERVER_API_URL + value: https://paw-unleash-api.nav.cloud.nais.io/api leaderElection: true kafka: pool: nav-prod @@ -133,6 +136,7 @@ spec: - host: norg2.prod-fss-pub.nais.io - host: oppgave.prod-fss-pub.nais.io - host: ereg-services.prod-fss-pub.nais.io + - host: paw-unleash-api.nav.cloud.nais.io rules: - application: aareg-services-nais namespace: arbeidsforhold diff --git a/nais/unleash-apitoken-dev.yaml b/nais/unleash-apitoken-dev.yaml new file mode 100644 index 000000000..f22f9fbc3 --- /dev/null +++ b/nais/unleash-apitoken-dev.yaml @@ -0,0 +1,14 @@ +apiVersion: unleash.nais.io/v1 +kind: ApiToken +metadata: + name: veilarbregistrering-unleash + namespace: paw + labels: + "team": "paw" +spec: + unleashInstance: + apiVersion: unleash.nais.io/v1 + kind: RemoteUnleash + name: paw + secretName: veilarbregistrering-unleash-api-token + environment: development diff --git a/nais/unleash-apitoken-prod.yaml b/nais/unleash-apitoken-prod.yaml new file mode 100644 index 000000000..6a5149f9a --- /dev/null +++ b/nais/unleash-apitoken-prod.yaml @@ -0,0 +1,14 @@ +apiVersion: unleash.nais.io/v1 +kind: ApiToken +metadata: + name: veilarbregistrering-unleash + namespace: paw + labels: + "team": "paw" +spec: + unleashInstance: + apiVersion: unleash.nais.io/v1 + kind: RemoteUnleash + name: paw + secretName: veilarbregistrering-unleash-api-token + environment: production diff --git a/pom.xml b/pom.xml index 99ff200e5..d9110d3eb 100644 --- a/pom.xml +++ b/pom.xml @@ -76,11 +76,6 @@ job ${common.version} - - no.nav.common - feature-toggle - ${common.version} - no.nav.common token-client @@ -188,6 +183,11 @@ runtime 1 + + io.getunleash + unleash-client-java + 9.1.1 + diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/arbeidssoker/formidlingsgruppe/kafka/FormidlingsgruppeKafkaConsumer.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/arbeidssoker/formidlingsgruppe/kafka/FormidlingsgruppeKafkaConsumer.kt index 33b7130e5..76348cf45 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/arbeidssoker/formidlingsgruppe/kafka/FormidlingsgruppeKafkaConsumer.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/arbeidssoker/formidlingsgruppe/kafka/FormidlingsgruppeKafkaConsumer.kt @@ -1,6 +1,7 @@ package no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka -import no.nav.common.featuretoggle.UnleashClient +import io.getunleash.DefaultUnleash +import io.getunleash.Unleash import no.nav.common.log.MDCConstants import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.FormidlingsgruppeMottakService import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka.FormidlingsgruppeMapper.Companion.map @@ -25,7 +26,7 @@ class FormidlingsgruppeKafkaConsumer internal constructor( private val kafkaConsumerProperties: Properties, private val topic: String, private val formidlingsgruppeMottakService: FormidlingsgruppeMottakService, - private val unleashClient: UnleashClient + private val unleashClient: Unleash ) : Runnable { init { val forsinkelseIMinutterVedOppstart = 5 @@ -96,4 +97,4 @@ class FormidlingsgruppeKafkaConsumer internal constructor( private const val mdcTopicKey = "topic" private const val KILL_SWITCH_TOGGLE_NAME = "veilarbregistrering.stopKonsumeringAvFormidlingsgruppe" } -} \ No newline at end of file +} diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/arbeidssoker/meldekort/kafka/MeldekortKafkaConsumer.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/arbeidssoker/meldekort/kafka/MeldekortKafkaConsumer.kt index e5888ae9c..3215d2c4b 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/arbeidssoker/meldekort/kafka/MeldekortKafkaConsumer.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/arbeidssoker/meldekort/kafka/MeldekortKafkaConsumer.kt @@ -1,6 +1,6 @@ package no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.kafka -import no.nav.common.featuretoggle.UnleashClient +import io.getunleash.Unleash import no.nav.common.log.MDCConstants import no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.MeldekortMottakService import no.nav.fo.veilarbregistrering.config.objectMapper @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit class MeldekortKafkaConsumer internal constructor( private val kafkaConsumerProperties: Properties, private val topic: String, - private val unleashClient: UnleashClient, + private val unleashClient: Unleash, private val meldekortMottakService: MeldekortMottakService ) : Runnable { init { @@ -93,4 +93,4 @@ class MeldekortKafkaConsumer internal constructor( private const val KILL_SWITCH_TOGGLE_NAME = "veilarbregistrering.stopKonsumeringAvMeldekort" } -} \ No newline at end of file +} diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/config/ServiceBeansConfig.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/config/ServiceBeansConfig.kt index 4e517ca90..6c748657e 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/config/ServiceBeansConfig.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/config/ServiceBeansConfig.kt @@ -1,7 +1,7 @@ package no.nav.fo.veilarbregistrering.config +import io.getunleash.Unleash import no.nav.common.auth.context.AuthContextHolder -import no.nav.common.featuretoggle.UnleashClient import no.nav.common.health.selftest.SelfTestChecks import no.nav.common.job.leader_election.LeaderElectionClient import no.nav.fo.veilarbregistrering.aktorIdCache.AktorIdCacheService @@ -189,7 +189,7 @@ class ServiceBeansConfig { fun sykmeldtResource( tilgangskontrollService: TilgangskontrollService, userService: UserService, - unleashClient: UnleashClient, + unleashClient: Unleash, sykmeldtRegistreringService: SykmeldtRegistreringService, navVeilederService: NavVeilederService, ): SykmeldtResource { @@ -201,7 +201,7 @@ class ServiceBeansConfig { @Bean fun reaktiveringResource( userService: UserService, - unleashClient: UnleashClient, + unleashClient: Unleash, tilgangskontrollService: TilgangskontrollService, reaktiveringBrukerService: ReaktiveringBrukerService ): ReaktiveringResource { @@ -216,7 +216,7 @@ class ServiceBeansConfig { userService: UserService, brukerRegistreringService: BrukerRegistreringService, navVeilederService: NavVeilederService, - unleashClient: UnleashClient + unleashClient: Unleash ): OrdinaerBrukerRegistreringResource { return OrdinaerBrukerRegistreringResource( tilgangskontrollService, userService, brukerRegistreringService, navVeilederService, unleashClient @@ -259,7 +259,7 @@ class ServiceBeansConfig { } @Bean - fun featuretoggleResource(unleashClient: UnleashClient): FeaturetoggleResource { + fun featuretoggleResource(unleashClient: Unleash): FeaturetoggleResource { return FeaturetoggleResource(unleashClient) } diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/ByUserIdStrategy.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/ByUserIdStrategy.kt deleted file mode 100644 index 2bd71c4e8..000000000 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/ByUserIdStrategy.kt +++ /dev/null @@ -1,28 +0,0 @@ -package no.nav.fo.veilarbregistrering.featuretoggle - -import no.finn.unleash.strategy.Strategy -import no.nav.common.auth.context.AuthContextHolder -import org.slf4j.LoggerFactory - -class ByUserIdStrategy(private val authContextHolder: AuthContextHolder) : Strategy { - - override fun getName(): String = "byUserId" - - override fun isEnabled(parameters: MutableMap): Boolean { - - LOG.info("ByUserIdStrategy.isEnabled?") - - val navIdentIKontekst: String = authContextHolder.navIdent.get().get() - - LOG.info("Nav Ident i kontekst: {}", navIdentIKontekst) - - return parameters["user"] - ?.split(',') - ?.any { navIdentIKontekst == it } - ?: false - } - - companion object { - private val LOG = LoggerFactory.getLogger(ByUserIdStrategy::class.java) - } -} \ No newline at end of file diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/UnleashConfig.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/UnleashConfig.kt index 1d2211792..2327e0fd2 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/UnleashConfig.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/UnleashConfig.kt @@ -1,9 +1,8 @@ package no.nav.fo.veilarbregistrering.featuretoggle -import no.nav.common.auth.context.AuthContextHolder -import no.nav.common.featuretoggle.UnleashClient -import no.nav.common.featuretoggle.UnleashClientImpl -import no.nav.fo.veilarbregistrering.config.requireApplicationName +import io.getunleash.DefaultUnleash +import io.getunleash.Unleash +import io.getunleash.util.UnleashConfig import no.nav.fo.veilarbregistrering.config.requireProperty import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -12,15 +11,20 @@ import org.springframework.context.annotation.Configuration class UnleashConfig { @Bean - fun unleashClient(authContextHolder: AuthContextHolder): UnleashClient { - return UnleashClientImpl( - requireProperty(UNLEASH_API_URL_PROPERTY), - requireApplicationName(), - listOf(ByUserIdStrategy(authContextHolder)) - ) + fun unleashClient(): Unleash { + val config = UnleashConfig.builder() + .appName(APP_NAME) + .instanceId(APP_NAME) + .unleashAPI(requireProperty(UNLEASH_SERVER_API_URL)) + .apiKey(requireProperty(UNLEASH_SERVER_API_TOKEN)) + .build() + + return DefaultUnleash(config) } companion object { - const val UNLEASH_API_URL_PROPERTY = "UNLEASH_API_URL" + const val UNLEASH_SERVER_API_URL = "UNLEASH_SERVER_API_URL" + const val UNLEASH_SERVER_API_TOKEN = "UNLEASH_SERVER_API_TOKEN" + const val APP_NAME = "veilarbregistrering" } -} \ No newline at end of file +} diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/resources/FeaturetoggleResource.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/resources/FeaturetoggleResource.kt index caf5830ee..718411472 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/resources/FeaturetoggleResource.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/resources/FeaturetoggleResource.kt @@ -1,15 +1,15 @@ package no.nav.fo.veilarbregistrering.featuretoggle.resources -import no.nav.common.featuretoggle.UnleashClient +import io.getunleash.Unleash import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @RestController -class FeaturetoggleResource(private val unleashClient: UnleashClient) { +class FeaturetoggleResource(private val unleashClient: Unleash) { @GetMapping("/api/featuretoggle") fun hentFeatureToggles(@RequestParam("feature") vararg featureName: String): Map { return featureName.associateWith { unleashClient.isEnabled(it) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/helsesjekk/HelsesjekkConfig.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/helsesjekk/HelsesjekkConfig.kt index 20a2cd804..82d12fed3 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/helsesjekk/HelsesjekkConfig.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/helsesjekk/HelsesjekkConfig.kt @@ -1,7 +1,6 @@ package no.nav.fo.veilarbregistrering.helsesjekk import no.nav.common.abac.Pep -import no.nav.common.featuretoggle.UnleashClient import no.nav.common.health.selftest.SelfTestCheck import no.nav.common.health.selftest.SelfTestChecks import no.nav.common.health.selftest.SelfTestMeterBinder @@ -23,7 +22,7 @@ class HelsesjekkConfig { fun selfTestChecks( dbHelsesjekk: DatabaseHelsesjekk, veilarbPep: Pep, - unleashClient: UnleashClient, +// unleashClient: Unleash, oppfolgingClient: OppfolgingClient, krrClient: DigDirKrrProxyClient, aaregRestClient: AaregRestClient, @@ -35,7 +34,7 @@ class HelsesjekkConfig { val selfTestChecks = listOf( SelfTestCheck("Ping (sporring) mot Databasen til veilarregistrering.", true, dbHelsesjekk), SelfTestCheck("Ping mot ABAC tilgangskontroll", true, veilarbPep.abacClient), - SelfTestCheck("Ping mot Unleash (tilbyr feature-toggles)", false, unleashClient), +// SelfTestCheck("Ping mot Unleash (tilbyr feature-toggles)", false, unleashClient), SelfTestCheck("Ping Oppfolging", false, oppfolgingClient), SelfTestCheck("Ping Kontakt og reservasjonsregisteret (KRR)", false, krrClient), SelfTestCheck("Ping Arbeid og arbeidstager registeret (Aareg)", false, aaregRestClient), diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/kafka/KafkaConfig.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/kafka/KafkaConfig.kt index 200c410f5..22b748b0b 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/kafka/KafkaConfig.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/kafka/KafkaConfig.kt @@ -4,9 +4,9 @@ import io.confluent.kafka.schemaregistry.client.SchemaRegistryClientConfig import io.confluent.kafka.serializers.KafkaAvroDeserializerConfig import io.confluent.kafka.serializers.KafkaAvroSerializer import io.confluent.kafka.serializers.KafkaAvroSerializerConfig +import io.getunleash.Unleash import no.nav.arbeid.soker.profilering.ArbeidssokerProfilertEvent import no.nav.arbeid.soker.registrering.ArbeidssokerRegistrertEvent -import no.nav.common.featuretoggle.UnleashClient import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.FormidlingsgruppeMottakService import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka.FormidlingsgruppeKafkaConsumer import no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.MeldekortMottakService @@ -89,7 +89,7 @@ class KafkaConfig { @Bean fun formidlingsgruppeKafkaConsumer( - unleashClient: UnleashClient, + unleashClient: Unleash, formidlingsgruppeMottakService: FormidlingsgruppeMottakService ): FormidlingsgruppeKafkaConsumer { val envSuffix = if (isProduction()) "p" else "q" @@ -107,7 +107,7 @@ class KafkaConfig { @Bean fun meldekortKafkaConsumer( - unleashClient: UnleashClient, + unleashClient: Unleash, meldekortMottakService: MeldekortMottakService ): MeldekortKafkaConsumer { val envSuffix = if (isProduction()) "p" else "q1" diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/ordinaer/resources/OrdinaerBrukerRegistreringResource.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/ordinaer/resources/OrdinaerBrukerRegistreringResource.kt index 923316e18..c6716b5b5 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/ordinaer/resources/OrdinaerBrukerRegistreringResource.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/ordinaer/resources/OrdinaerBrukerRegistreringResource.kt @@ -1,6 +1,6 @@ package no.nav.fo.veilarbregistrering.registrering.ordinaer.resources -import no.nav.common.featuretoggle.UnleashClient +import io.getunleash.Unleash import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService import no.nav.fo.veilarbregistrering.bruker.UserService import no.nav.fo.veilarbregistrering.registrering.ordinaer.BrukerRegistreringService @@ -18,7 +18,7 @@ class OrdinaerBrukerRegistreringResource( private val userService: UserService, private val brukerRegistreringService: BrukerRegistreringService, private val navVeilederService: NavVeilederService, - private val unleashClient: UnleashClient + private val unleashClient: Unleash ) : OrdinaerBrukerRegistreringApi { @PostMapping("/fullfoerordinaerregistrering") @@ -38,4 +38,4 @@ class OrdinaerBrukerRegistreringResource( } private fun tjenesteErNede(): Boolean = unleashClient.isEnabled("arbeidssokerregistrering.nedetid") -} \ No newline at end of file +} diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/publisering/scheduler/PubliseringAvRegistreringEventsScheduler.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/publisering/scheduler/PubliseringAvRegistreringEventsScheduler.kt index 3f2c92ee3..99383f8ed 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/publisering/scheduler/PubliseringAvRegistreringEventsScheduler.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/publisering/scheduler/PubliseringAvRegistreringEventsScheduler.kt @@ -1,6 +1,6 @@ package no.nav.fo.veilarbregistrering.registrering.publisering.scheduler -import no.nav.common.featuretoggle.UnleashClient +import io.getunleash.Unleash import no.nav.common.job.leader_election.LeaderElectionClient import no.nav.fo.veilarbregistrering.log.CallId import no.nav.fo.veilarbregistrering.registrering.publisering.PubliseringAvEventsService @@ -11,7 +11,7 @@ import org.springframework.scheduling.annotation.Scheduled class PubliseringAvRegistreringEventsScheduler( private val publiseringAvEventsService: PubliseringAvEventsService, private val leaderElectionClient: LeaderElectionClient, - private val unleashClient: UnleashClient, + private val unleashClient: Unleash ) { @Scheduled(cron = HVERT_TIENDE_SEKUND) fun publiserRegistreringEvents() { diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/publisering/scheduler/PubliseringSchedulerConfig.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/publisering/scheduler/PubliseringSchedulerConfig.kt index 62fe77cdb..e6de9afc2 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/publisering/scheduler/PubliseringSchedulerConfig.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/publisering/scheduler/PubliseringSchedulerConfig.kt @@ -1,6 +1,6 @@ package no.nav.fo.veilarbregistrering.registrering.publisering.scheduler -import no.nav.common.featuretoggle.UnleashClient +import io.getunleash.Unleash import no.nav.common.job.leader_election.LeaderElectionClient import no.nav.common.job.leader_election.LeaderElectionHttpClient import no.nav.fo.veilarbregistrering.registrering.publisering.PubliseringAvEventsService @@ -21,11 +21,11 @@ class PubliseringSchedulerConfig { fun publiseringAvRegistreringEventsScheduler( publiseringAvEventsService: PubliseringAvEventsService, leaderElectionClient: LeaderElectionClient, - unleashClient: UnleashClient + unleashClient: Unleash ): PubliseringAvRegistreringEventsScheduler { return PubliseringAvRegistreringEventsScheduler( publiseringAvEventsService, leaderElectionClient, unleashClient) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/reaktivering/resources/ReaktiveringResource.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/reaktivering/resources/ReaktiveringResource.kt index 27b406184..46088ca2a 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/reaktivering/resources/ReaktiveringResource.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/reaktivering/resources/ReaktiveringResource.kt @@ -1,6 +1,6 @@ package no.nav.fo.veilarbregistrering.registrering.reaktivering.resources -import no.nav.common.featuretoggle.UnleashClient +import io.getunleash.Unleash import no.nav.fo.veilarbregistrering.arbeidssoker.perioder.resources.Fnr import no.nav.fo.veilarbregistrering.autorisasjon.CefMelding import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.* @RequestMapping("/api") class ReaktiveringResource( private val userService: UserService, - private val unleashClient: UnleashClient, + private val unleashClient: Unleash, private val tilgangskontrollService: TilgangskontrollService, private val reaktiveringBrukerService: ReaktiveringBrukerService ) : ReaktiveringApi { @@ -54,4 +54,4 @@ class ReaktiveringResource( } private fun tjenesteErNede(): Boolean = unleashClient.isEnabled("arbeidssokerregistrering.nedetid") -} \ No newline at end of file +} diff --git a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/sykmeldt/resources/SykmeldtResource.kt b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/sykmeldt/resources/SykmeldtResource.kt index 7cdd581fa..83b8f6280 100644 --- a/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/sykmeldt/resources/SykmeldtResource.kt +++ b/src/main/kotlin/no/nav/fo/veilarbregistrering/registrering/sykmeldt/resources/SykmeldtResource.kt @@ -1,6 +1,6 @@ package no.nav.fo.veilarbregistrering.registrering.sykmeldt.resources -import no.nav.common.featuretoggle.UnleashClient +import io.getunleash.Unleash import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService import no.nav.fo.veilarbregistrering.bruker.UserService import no.nav.fo.veilarbregistrering.registrering.sykmeldt.SykmeldtRegistrering @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.* class SykmeldtResource( private val tilgangskontrollService: TilgangskontrollService, private val userService: UserService, - private val unleashClient: UnleashClient, + private val unleashClient: Unleash, private val sykmeldtRegistreringService: SykmeldtRegistreringService, private val navVeilederService: NavVeilederService ) : SykmeldtApi { @@ -32,4 +32,4 @@ class SykmeldtResource( } private fun tjenesteErNede(): Boolean = unleashClient.isEnabled("arbeidssokerregistrering.nedetid") -} \ No newline at end of file +} diff --git a/src/test/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/UnleashConfig.kt b/src/test/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/UnleashConfig.kt index 3b5476b3e..c1e3b1214 100644 --- a/src/test/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/UnleashConfig.kt +++ b/src/test/kotlin/no/nav/fo/veilarbregistrering/featuretoggle/UnleashConfig.kt @@ -1,12 +1,12 @@ package no.nav.fo.veilarbregistrering.featuretoggle +import io.getunleash.Unleash import io.mockk.mockk -import no.nav.common.featuretoggle.UnleashClient import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @Configuration class UnleashConfig { @Bean - fun unleashClient(): UnleashClient = mockk(relaxed = true) -} \ No newline at end of file + fun unleashClient(): Unleash = mockk(relaxed = true) +} diff --git a/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/bruker/HentRegistreringServiceTest.kt b/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/bruker/HentRegistreringServiceTest.kt index fdcb27298..a04065e6b 100644 --- a/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/bruker/HentRegistreringServiceTest.kt +++ b/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/bruker/HentRegistreringServiceTest.kt @@ -1,8 +1,8 @@ package no.nav.fo.veilarbregistrering.registrering.bruker +import io.getunleash.Unleash import io.mockk.every import io.mockk.mockk -import no.nav.common.featuretoggle.UnleashClient import no.nav.fo.veilarbregistrering.bruker.AktorId import no.nav.fo.veilarbregistrering.bruker.Bruker import no.nav.fo.veilarbregistrering.bruker.Foedselsnummer @@ -11,10 +11,10 @@ import no.nav.fo.veilarbregistrering.orgenhet.NavEnhet import no.nav.fo.veilarbregistrering.orgenhet.Norg2Gateway import no.nav.fo.veilarbregistrering.profilering.ProfileringRepository import no.nav.fo.veilarbregistrering.profilering.ProfileringTestdataBuilder.lagProfilering -import no.nav.fo.veilarbregistrering.registrering.ordinaer.OrdinaerBrukerRegistreringTestdataBuilder.gyldigBrukerRegistrering -import no.nav.fo.veilarbregistrering.registrering.veileder.ManuellRegistreringRepository import no.nav.fo.veilarbregistrering.registrering.ordinaer.BrukerRegistreringRepository +import no.nav.fo.veilarbregistrering.registrering.ordinaer.OrdinaerBrukerRegistreringTestdataBuilder.gyldigBrukerRegistrering import no.nav.fo.veilarbregistrering.registrering.sykmeldt.SykmeldtRegistreringRepository +import no.nav.fo.veilarbregistrering.registrering.veileder.ManuellRegistreringRepository import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -27,7 +27,7 @@ internal class HentRegistreringServiceTest { @BeforeEach fun setup() { val manuellRegistreringRepository: ManuellRegistreringRepository = mockk() - val unleashClient: UnleashClient = mockk() + val unleashClient: Unleash = mockk() val norg2Gateway: Norg2Gateway = mockk() val profileringRepository: ProfileringRepository = mockk() val sykmeldtRegistreringRepository: SykmeldtRegistreringRepository = mockk() @@ -92,4 +92,4 @@ internal class HentRegistreringServiceTest { Enhetnr("5678") to NavEnhet("5678", "TEST2") ) } -} \ No newline at end of file +} diff --git a/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/ordinaer/resources/OrdinaerBrukerRegistreringResourceTest.kt b/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/ordinaer/resources/OrdinaerBrukerRegistreringResourceTest.kt index 515e7ba07..9830a28cc 100644 --- a/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/ordinaer/resources/OrdinaerBrukerRegistreringResourceTest.kt +++ b/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/ordinaer/resources/OrdinaerBrukerRegistreringResourceTest.kt @@ -1,12 +1,25 @@ package no.nav.fo.veilarbregistrering.registrering.ordinaer.resources -import io.mockk.* +import io.getunleash.Unleash +import io.mockk.clearAllMocks +import io.mockk.every +import io.mockk.mockk +import io.mockk.mockkStatic +import io.mockk.verify +import javax.servlet.http.HttpServletRequest import no.nav.common.auth.context.AuthContextHolder -import no.nav.common.featuretoggle.UnleashClient import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService import no.nav.fo.veilarbregistrering.besvarelse.Besvarelse import no.nav.fo.veilarbregistrering.besvarelse.HelseHinderSvar -import no.nav.fo.veilarbregistrering.bruker.* +import no.nav.fo.veilarbregistrering.bruker.AktorId +import no.nav.fo.veilarbregistrering.bruker.Bruker +import no.nav.fo.veilarbregistrering.bruker.Foedselsnummer +import no.nav.fo.veilarbregistrering.bruker.FoedselsnummerTestdataBuilder +import no.nav.fo.veilarbregistrering.bruker.Gruppe +import no.nav.fo.veilarbregistrering.bruker.Ident +import no.nav.fo.veilarbregistrering.bruker.Identer +import no.nav.fo.veilarbregistrering.bruker.PdlOppslagGateway +import no.nav.fo.veilarbregistrering.bruker.UserService import no.nav.fo.veilarbregistrering.config.RequestContext import no.nav.fo.veilarbregistrering.registrering.ordinaer.BrukerRegistreringService import no.nav.fo.veilarbregistrering.registrering.ordinaer.OrdinaerBrukerRegistreringTestdataBuilder @@ -22,7 +35,6 @@ import org.springframework.http.MediaType import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.post -import javax.servlet.http.HttpServletRequest @AutoConfigureMockMvc @WebMvcTest @@ -101,7 +113,7 @@ private class OrdinaerBrukerRegistreringResourceConfig { userService: UserService, brukerRegistreringService: BrukerRegistreringService, navVeilederService: NavVeilederService, - unleashClient: UnleashClient + unleashClient: Unleash ) = OrdinaerBrukerRegistreringResource( tilgangskontrollService, userService, @@ -119,7 +131,7 @@ private class OrdinaerBrukerRegistreringResourceConfig { } @Bean - fun unleashClient(): UnleashClient = mockk(relaxed = true) + fun unleashClient(): Unleash = mockk(relaxed = true) @Bean fun pdlOppslagGateway(): PdlOppslagGateway = mockk() @@ -133,4 +145,4 @@ private class OrdinaerBrukerRegistreringResourceConfig { @Bean fun userService(pdlOppslagGateway: PdlOppslagGateway, authContextHolder: AuthContextHolder): UserService = UserService(pdlOppslagGateway, authContextHolder) -} \ No newline at end of file +} diff --git a/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/reaktivering/resources/ReaktiveringResourceTest.kt b/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/reaktivering/resources/ReaktiveringResourceTest.kt index d49f85f30..67815607c 100644 --- a/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/reaktivering/resources/ReaktiveringResourceTest.kt +++ b/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/reaktivering/resources/ReaktiveringResourceTest.kt @@ -1,14 +1,21 @@ package no.nav.fo.veilarbregistrering.registrering.reaktivering.resources +import io.getunleash.Unleash import io.mockk.clearAllMocks import io.mockk.every import io.mockk.mockk import io.mockk.mockkStatic +import javax.servlet.http.HttpServletRequest +import kotlin.test.assertNotNull import no.nav.common.auth.context.AuthContextHolder -import no.nav.common.featuretoggle.UnleashClient import no.nav.fo.veilarbregistrering.arbeidssoker.perioder.resources.Fnr import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService -import no.nav.fo.veilarbregistrering.bruker.* +import no.nav.fo.veilarbregistrering.bruker.Foedselsnummer +import no.nav.fo.veilarbregistrering.bruker.Gruppe +import no.nav.fo.veilarbregistrering.bruker.Ident +import no.nav.fo.veilarbregistrering.bruker.Identer +import no.nav.fo.veilarbregistrering.bruker.PdlOppslagGateway +import no.nav.fo.veilarbregistrering.bruker.UserService import no.nav.fo.veilarbregistrering.config.RequestContext import no.nav.fo.veilarbregistrering.config.objectMapper import no.nav.fo.veilarbregistrering.registrering.reaktivering.ReaktiveringBrukerService @@ -24,8 +31,6 @@ import org.springframework.http.MediaType import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.post -import javax.servlet.http.HttpServletRequest -import kotlin.test.assertNotNull @AutoConfigureMockMvc @WebMvcTest @@ -107,7 +112,7 @@ private class ReaktiveringResourceConfig { @Bean fun reaktiveringResource( userService: UserService, - unleashClient: UnleashClient, + unleashClient: Unleash, tilgangskontrollService: TilgangskontrollService, reaktiveringBrukerService: ReaktiveringBrukerService ) = ReaktiveringResource( @@ -118,7 +123,7 @@ private class ReaktiveringResourceConfig { ) @Bean - fun unleashClient(): UnleashClient = mockk(relaxed = true) + fun unleashClient(): Unleash = mockk(relaxed = true) @Bean fun pdlOppslagGateway(): PdlOppslagGateway = mockk() @@ -135,4 +140,4 @@ private class ReaktiveringResourceConfig { @Bean fun reaktiveringBrukerService(): ReaktiveringBrukerService = mockk(relaxed = true) -} \ No newline at end of file +} diff --git a/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/sykmeldt/resources/SykmeldtResourceTest.kt b/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/sykmeldt/resources/SykmeldtResourceTest.kt index 0b3fb0cde..10c64c9e9 100644 --- a/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/sykmeldt/resources/SykmeldtResourceTest.kt +++ b/src/test/kotlin/no/nav/fo/veilarbregistrering/registrering/sykmeldt/resources/SykmeldtResourceTest.kt @@ -1,14 +1,24 @@ package no.nav.fo.veilarbregistrering.registrering.sykmeldt.resources -import io.mockk.* +import io.getunleash.Unleash +import io.mockk.clearAllMocks +import io.mockk.every +import io.mockk.mockk +import io.mockk.mockkStatic +import io.mockk.verify +import javax.servlet.http.HttpServletRequest import no.nav.common.auth.context.AuthContextHolder -import no.nav.common.featuretoggle.UnleashClient import no.nav.fo.veilarbregistrering.FileToJson import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService import no.nav.fo.veilarbregistrering.besvarelse.Besvarelse import no.nav.fo.veilarbregistrering.besvarelse.FremtidigSituasjonSvar import no.nav.fo.veilarbregistrering.besvarelse.TilbakeIArbeidSvar -import no.nav.fo.veilarbregistrering.bruker.* +import no.nav.fo.veilarbregistrering.bruker.Foedselsnummer +import no.nav.fo.veilarbregistrering.bruker.Gruppe +import no.nav.fo.veilarbregistrering.bruker.Ident +import no.nav.fo.veilarbregistrering.bruker.Identer +import no.nav.fo.veilarbregistrering.bruker.PdlOppslagGateway +import no.nav.fo.veilarbregistrering.bruker.UserService import no.nav.fo.veilarbregistrering.config.RequestContext import no.nav.fo.veilarbregistrering.registrering.sykmeldt.SykmeldtRegistreringService import no.nav.fo.veilarbregistrering.registrering.sykmeldt.SykmeldtRegistreringTestdataBuilder @@ -25,7 +35,6 @@ import org.springframework.http.MediaType import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.post -import javax.servlet.http.HttpServletRequest @AutoConfigureMockMvc @WebMvcTest @@ -94,7 +103,7 @@ private class SykmeldtResourceConfig { fun sykmeldtResource( tilgangskontrollService: TilgangskontrollService, userService: UserService, - unleashClient: UnleashClient, + unleashClient: Unleash, sykmeldtRegistreringService: SykmeldtRegistreringService, navVeilederService: NavVeilederService ) = SykmeldtResource( @@ -114,7 +123,7 @@ private class SykmeldtResourceConfig { fun tilgangskontrollService(): TilgangskontrollService = mockk(relaxed = true) @Bean - fun unleashClient(): UnleashClient = mockk(relaxed = true) + fun unleashClient(): Unleash = mockk(relaxed = true) @Bean fun pdlOppslagGateway(): PdlOppslagGateway = mockk() @@ -128,4 +137,4 @@ private class SykmeldtResourceConfig { @Bean fun sykmeldtRegistreringService(): SykmeldtRegistreringService = mockk(relaxed = true) -} \ No newline at end of file +}