Skip to content

Commit

Permalink
chore: checking for invalid oppgaveId in getOppgaveRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
jaflaten committed Dec 5, 2024
1 parent 79e8ff6 commit b242fd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ class NasjonalOppgaveService(
return updated
}

fun isValidOppgaveId(oppgaveId: String): Boolean {
val regex = Regex("^\\d{9}$|^[a-zA-Z0-9]{1,20}$")
return oppgaveId.matches(regex)
}

fun findByOppgaveId(oppgaveId: String): NasjonalManuellOppgaveDAO? {
if(!isValidOppgaveId(oppgaveId))
Expand Down Expand Up @@ -269,3 +265,8 @@ private fun getLoggingMeta(sykmeldingId: String, oppgave: NasjonalManuellOppgave
)
}
}

fun isValidOppgaveId(oppgaveId: String): Boolean {
val regex = Regex("^\\d{9}$|^[a-zA-Z0-9]{1,20}$")
return oppgaveId.matches(regex)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import no.nav.sykdig.digitalisering.papirsykmelding.api.model.AvvisSykmeldingReq
import no.nav.sykdig.digitalisering.papirsykmelding.api.model.PapirManuellOppgave
import no.nav.sykdig.digitalisering.papirsykmelding.api.model.SmRegistreringManuell
import no.nav.sykdig.digitalisering.papirsykmelding.api.model.Sykmelder
import no.nav.sykdig.digitalisering.papirsykmelding.isValidOppgaveId
import org.springframework.beans.factory.annotation.Value
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
Expand Down Expand Up @@ -57,6 +58,8 @@ class SmregistreringClient(
authorization: String,
oppgaveId: String,
): ResponseEntity<PapirManuellOppgave> {
if(!isValidOppgaveId(oppgaveId))
throw IllegalArgumentException("Invalid oppgaveId does not contain only alphanumerical characters. oppgaveId: $oppgaveId")
val headers = HttpHeaders()
headers.contentType = MediaType.APPLICATION_JSON
headers.setBearerAuth(removeBearerPrefix(authorization))
Expand Down

0 comments on commit b242fd6

Please sign in to comment.