-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OK-751 käyttöoikeuskäsittelyn tehostamista, OK-443 client-kirjaston v…
…iimeistely OK-751 * käyttäjän oikeudet sessioon * tarkistetaan onko tulllut uusia käyttöoikeuksia kantaan ja päivitetään sessio tarvittaessa * käsitellään käyttäjän käyttöoikeuksista vain ne mitä palvelusta on käytössä Muut * tarkempi organisaation validointi viestirajapintaan * integraatiotesti raportointi-apille OK-443 * korjattu client-kirjaston login-polku ja täydennetty integraatiotestejä * päivitetty versio * maven flatten plugin kirjastoon * snapshot-version kovakoodaus pois ja muuttuja tilalle * päivitetty client-kirjaston readme ja käyttöoikeusattribuutit yhdenmukaiseen järjestykseen * static metodit pois kirjaston java interfaceista
- Loading branch information
Showing
53 changed files
with
1,170 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
500 changes: 500 additions & 0 deletions
500
integraatio/src/test/scala/fi/oph/viestinvalitys/RaportointiApiIntegraatioTest.scala
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package fi.oph.viestinvalitys; | ||
|
||
import fi.oph.viestinvalitys.vastaanotto.model.*; | ||
import fi.oph.viestinvalitys.vastaanotto.resource.VastaanottajaResponseImpl; | ||
import io.netty.handler.codec.http.cookie.Cookie; | ||
import org.asynchttpclient.Dsl; | ||
import org.asynchttpclient.AsyncHttpClient; | ||
|
@@ -12,7 +11,6 @@ | |
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.core.env.Environment; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.util.Optional; | ||
import java.util.List; | ||
import java.util.Iterator; | ||
|
@@ -42,7 +40,7 @@ private String getSessionCookie() throws Exception { | |
|
||
private ViestinvalitysClient getClient() throws Exception { | ||
String port = environment.getProperty("local.server.port"); | ||
return ViestinvalitysClient.builder() | ||
return ClientBuilder.viestinvalitysClientBuilder() | ||
.withEndpoint("http://localhost:" + port) | ||
.withSessionId(this.getSessionCookie()) | ||
.withCallerId(CALLER_ID) | ||
|
@@ -51,7 +49,8 @@ private ViestinvalitysClient getClient() throws Exception { | |
|
||
@Test | ||
public void testLuoLahetys() throws Exception { | ||
LuoLahetysSuccessResponse response = this.getClient().luoLahetys(Lahetys.builder() | ||
LuoLahetysSuccessResponse response = this.getClient().luoLahetys( | ||
ViestinvalitysBuilder.lahetysBuilder() | ||
.withOtsikko("otsikko") | ||
.withLahettavaPalvelu("palvelu") | ||
.withLahettaja(Optional.empty(), "[email protected]") | ||
|
@@ -62,7 +61,7 @@ public void testLuoLahetys() throws Exception { | |
|
||
@Test | ||
public void testLuoLiite() throws Exception { | ||
LuoLiiteSuccessResponse response = this.getClient().luoLiite(Liite.builder() | ||
LuoLiiteSuccessResponse response = this.getClient().luoLiite(ViestinvalitysBuilder.liiteBuilder() | ||
.withFileName("test.png") | ||
.withBytes(getClass().getResourceAsStream("/screenshot.png").readAllBytes()) | ||
.withContentType("image/png") | ||
|
@@ -71,19 +70,22 @@ public void testLuoLiite() throws Exception { | |
|
||
@Test | ||
public void testLuoViesti() throws Exception { | ||
LuoViestiSuccessResponse response = this.getClient().luoViesti(Viesti.builder() | ||
LuoViestiSuccessResponse response = this.getClient().luoViesti(ViestinvalitysBuilder.viestiBuilder() | ||
.withOtsikko("otsikko") | ||
.withTextSisalto("sisältö") | ||
.withKielet("fi") | ||
.withVastaanottajat(Vastaanottajat.builder() | ||
.withVastaanottajat(ViestinvalitysBuilder.vastaanottajatBuilder() | ||
.withVastaanottaja(Optional.empty(), "[email protected]") | ||
.build()) | ||
.withMetadatat(Metadatat.builder() | ||
.withMetadatat(ViestinvalitysBuilder.metadatatBuilder() | ||
.withMetadata("avain", List.of("arvo1", "arvo2")) | ||
.build()) | ||
.withMaskit(Maskit.builder() | ||
.withMaskit(ViestinvalitysBuilder.maskitBuilder() | ||
.withMaski("salaisuus", "maskattu") | ||
.build()) | ||
.withKayttooikeusRajoitukset(ViestinvalitysBuilder.kayttooikeusrajoituksetBuilder() | ||
.withKayttooikeus("APP_HAKEMUS_CRUD", "1.2.246.562.10.240484683010") | ||
.build()) | ||
.withLahettavaPalvelu("palvelu") | ||
.withNormaaliPrioriteetti() | ||
.withLahettaja(Optional.empty(), "[email protected]") | ||
|
@@ -95,17 +97,17 @@ public void testLuoViesti() throws Exception { | |
public void testLiitaLiite() throws Exception { | ||
ViestinvalitysClient client = this.getClient(); | ||
|
||
LuoLiiteSuccessResponse liiteResponse = client.luoLiite(Liite.builder() | ||
LuoLiiteSuccessResponse liiteResponse = client.luoLiite(ViestinvalitysBuilder.liiteBuilder() | ||
.withFileName("test.png") | ||
.withBytes(getClass().getResourceAsStream("/screenshot.png").readAllBytes()) | ||
.withContentType("image/png") | ||
.build()); | ||
|
||
LuoViestiSuccessResponse viestiResponse = client.luoViesti(Viesti.builder() | ||
LuoViestiSuccessResponse viestiResponse = client.luoViesti(ViestinvalitysBuilder.viestiBuilder() | ||
.withOtsikko("otsikko") | ||
.withTextSisalto("sisältö") | ||
.withKielet("fi") | ||
.withVastaanottajat(Vastaanottajat.builder() | ||
.withVastaanottajat(ViestinvalitysBuilder.vastaanottajatBuilder() | ||
.withVastaanottaja(Optional.empty(), "[email protected]") | ||
.build()) | ||
.withLiitteidenTunnisteet(List.of(liiteResponse.getLiiteTunniste())) | ||
|
@@ -120,11 +122,11 @@ public void testLiitaLiite() throws Exception { | |
public void testGetVastaanottajat() throws Exception { | ||
ViestinvalitysClient client = this.getClient(); | ||
|
||
LuoViestiSuccessResponse viestiResponse = client.luoViesti(Viesti.builder() | ||
LuoViestiSuccessResponse viestiResponse = client.luoViesti(ViestinvalitysBuilder.viestiBuilder() | ||
.withOtsikko("otsikko") | ||
.withTextSisalto("sisältö") | ||
.withKielet("fi") | ||
.withVastaanottajat(Vastaanottajat.builder() | ||
.withVastaanottajat(ViestinvalitysBuilder.vastaanottajatBuilder() | ||
.withVastaanottaja(Optional.empty(), "[email protected]") | ||
.withVastaanottaja(Optional.empty(), "[email protected]") | ||
.build()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ Kirjaston avulla asiakasjärjestelmät voivat käyttää viestinvälityspalvelua | |
Client instanssi luodaan builderilla, esim: | ||
|
||
``` | ||
ViestinvalitysClient client = ViestinvalitysClient.builder() | ||
ViestinvalitysClient client = ClientBuilder.viestinvalitysClientBuilder() | ||
.withEndpoint(<viestinvälityspalvelun osoite, esim: "https://viestinvalitys.hahtuvaopintopolku.fi">) | ||
.withUsername(<käyttäjätunnus>) | ||
.withPassword(<salana>) | ||
|
@@ -16,19 +16,55 @@ Client instanssi luodaan builderilla, esim: | |
.build() | ||
``` | ||
|
||
Tämän jälkeen client-instanssilla voi luoda pyyntöjä jotka luovat liitteitä, lähetyksiä, ja viestejä, sekä tarkastelevat näiden tilaa, Esim. viesti luodaan seuraavasti: | ||
Tämän jälkeen client-instanssilla voi luoda pyyntöjä jotka luovat liitteitä, lähetyksiä, ja viestejä, sekä tarkastelevat näiden tilaa, Esim. seuraavasti: | ||
|
||
Voidaan joko luoda ensin lähetys ja liittää samaan lähetykseen useita viestejä | ||
|
||
``` | ||
LuoViestiResponse response = viestinvalitysClient.luoViesti(Viesti.builder() | ||
LuolahetysResponse luoLahetysResponse = viestinvalitysClient.luoLahetys( | ||
ViestinvalitysBuilder.lahetysBuilder() | ||
.withOtsikko("Lahetyksen otsikko") | ||
.withLahettavaPalvelu("virkailijantyopoyta") | ||
.withLahettaja(Optional.empty(), "[email protected]") | ||
.withNormaaliPrioriteetti() | ||
.withSailytysaika(365) | ||
.withLahettavanVirkailijanOid("1.2.246.562.24.1") | ||
.build()) | ||
ViestinvalitysBuilder.viestiBuilder() | ||
.withOtsikko("viestin otsikko") | ||
.withHtmlSisalto("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /><title></title></head><body style=\"margin: 0; font-family: 'Open Sans', Arial, sans-serif;\"><H1>Otsikko</h1><p>Viestin sisältö</p><p>Ystävällisin terveisin<br/>Opintopolku</p></body></html>") | ||
.withKielet("fi") | ||
.withVastaanottajat(ViestinvalitysBuilder.vastaanottajatBuilder() | ||
.withVastaanottaja(Optional.empty(), "[email protected]") | ||
.build()) | ||
.withKayttooikeusRajoitukset(ViestinvalitysBuilder.kayttooikeusrajoituksetBuilder() | ||
.withKayttooikeus("APP_HAKEMUS_CRUD", "1.2.246.562.10.240484683010") | ||
.build()) | ||
.withLahetysTunniste(lahetysTunniste.toString) | ||
.build() | ||
``` | ||
|
||
Tai luoda viestejä erillisinä lähetyksinä | ||
``` | ||
LuoViestiResponse response = viestinvalitysClient.luoViesti( | ||
ViestinvalitysBuilder.viestiBuilder() | ||
.withOtsikko("testiotsikko") | ||
.withTextSisalto("testisisältö") | ||
.withKielet("fi") | ||
.withVastaanottajat(Vastaanottajat.builder() | ||
.withVastaanottajat(ViestinvalitysBuilder.vastaanottajatBuilder() | ||
.withVastaanottaja(Optional.empty(), "[email protected]") | ||
.build()) | ||
.withNormaaliPrioriteetti() | ||
.withSailytysAika(1) | ||
.withLahettavaPalvelu("virkailijatyopoyta") | ||
.withSailytysAika(365) | ||
.withLahettavaPalvelu("virkailijantyopoyta") | ||
.withKayttooikeusRajoitukset(ViestinvalitysBuilder.kayttooikeusrajoituksetBuilder() | ||
.withKayttooikeus("APP_HAKEMUS_CRUD", "1.2.246.562.10.240484683010") | ||
.build()) | ||
.withLahettaja(Optional.empty(), "[email protected]") | ||
.build()) | ||
``` | ||
### Kirjaston päivitys | ||
|
||
Jos kirjastoa on tarve muuttaa tai päivittää, nosta projektin parent-pomissa oleva revision | ||
ja päivitä uusi snapshot-numero clientia käyttäviin palveluihin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
kirjasto/src/main/scala/fi.oph.viestinvalitys/ClientBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package fi.oph.viestinvalitys; | ||
|
||
public class ClientBuilder { | ||
public static ViestinvalitysClient.EndpointBuilder viestinvalitysClientBuilder() { | ||
return new ViestinvalitysClientBuilderImpl(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...pinta/src/main/scala/fi/oph/viestinvalitys/vastaanotto/model/Kayttooikeusrajoitukset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fi.oph.viestinvalitys.vastaanotto.model; | ||
|
||
import java.util.Optional; | ||
import java.util.List; | ||
import fi.oph.viestinvalitys.vastaanotto.model.Viesti.Kayttooikeus; | ||
|
||
public interface Kayttooikeusrajoitukset { | ||
interface KayttooikeusrajoituksetBuilder { | ||
|
||
KayttooikeusrajoituksetBuilder withKayttooikeus(String oikeus, String organisaatio); | ||
|
||
List<Kayttooikeus> build(); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.