Skip to content

Commit

Permalink
Issue #653 (#655)
Browse files Browse the repository at this point in the history
Modificata gestione della versione di una stazione per indicare all'utente del cruscotto l'attivazione del modello unico di pagamento.
Eliminato vincolo di obbligatorieta' della password quando si abilita il modello unico.
Allineato backend per gestire la password opzionale.
Allineata testsuite.
  • Loading branch information
pintorig committed Nov 22, 2023
1 parent 6fb02e4 commit 55b9cec
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,28 @@ When method put
Then status 400

* match response == { categoria: 'RICHIESTA', codice: 'SINTASSI', descrizione: 'Richiesta non valida', dettaglio: '#notnull' }

Scenario Outline: Stazione V2 <field> non valida

* set stazione.versione = 'V2'
* set <fieldRequest> = <fieldValue>

Given url backofficeBaseurl
And path 'intermediari', idIntermediario, 'stazioni', idStazione
And headers basicAutenticationHeader
And request stazione
When method put
Then status 400

* match response == { categoria: 'RICHIESTA', codice: 'SINTASSI', descrizione: 'Richiesta non valida', dettaglio: '#notnull' }
* match response.dettaglio contains <fieldResponse>

Examples:
| field | fieldRequest | fieldValue | fieldResponse |
| password | stazione.password | loremIpsum | 'password' |
| abilitato | stazione.abilitato | null | 'abilitato' |
| abilitato | stazione.abilitato | 'zzz' | 'abilitato' |
| versione | stazione.versione | null | 'versione' |
| versione | stazione.versione | loremIpsum | 'versione' |
| versione | stazione.versione | 'zzz' | 'versione' |
| versione | stazione.versione | '' | 'versione' |
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,38 @@ And match response ==
versione : 'V1'
}
"""

Scenario: Configurazione stazione V2

* def stazione = read('classpath:test/api/backoffice/v1/intermediari/put/msg/stazione.json')
* set stazione.password = null
* set stazione.versione = 'V2'

Given url backofficeBaseurl
And path 'intermediari', idIntermediario
And headers basicAutenticationHeader
And request intermediario
When method put
Then assert responseStatus == 200 || responseStatus == 201

Given url backofficeBaseurl
And path 'intermediari', idIntermediario, 'stazioni', idStazione
And headers basicAutenticationHeader
And request stazione
When method put
Then assert responseStatus == 200 || responseStatus == 201

Given url backofficeBaseurl
And path 'intermediari', idIntermediario, 'stazioni', idStazione
And headers basicAutenticationHeader
When method get
Then status 200
And match response ==
"""
{
idStazione : '#(idStazione)',
abilitato : true,
domini : '#ignore',
versione : 'V2'
}
"""
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Objects;

import org.apache.commons.lang3.ArrayUtils;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down Expand Up @@ -145,9 +147,20 @@ private String toIndentedString(java.lang.Object o) {
@Override
public void validate() throws ValidationException {
ValidatorFactory vf = ValidatorFactory.newInstance();
vf.getValidator("password", this.password).notNull().minLength(1).maxLength(35);
vf.getValidator("abilitato", this.abilitato).notNull();
vf.getValidator("versione", this.versione).notNull();

// valore versione non valido
VersioneStazione versioneStazione = VersioneStazione.fromValue(this.getVersione());
if(versioneStazione == null) {
throw new ValidationException("Codifica inesistente per versione. Valore fornito [" + this.getVersione() + "] valori possibili " + ArrayUtils.toString(VersioneStazione.values()));
}

if(versioneStazione.equals(VersioneStazione.V1)) {
vf.getValidator("password", this.password).notNull().minLength(1).maxLength(35);
} else {
vf.getValidator("password", this.password).maxLength(35);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public static PutStazioneDTO getPutStazioneDTO(StazionePost stazionePost, String
stazione.setCodStazione(idStazione);
stazione.setPassword(stazionePost.getPassword());

if(stazione.getPassword() == null) {
stazione.setPassword("");
}

if(stazionePost.getVersione() != null) {
// valore versione non valido
VersioneStazione versioneStazione = VersioneStazione.fromValue(stazionePost.getVersione());
Expand Down Expand Up @@ -75,6 +79,10 @@ public static Stazione toRsModel(it.govpay.bd.model.Stazione stazione, List<it.g
rsModel.abilitato(stazione.isAbilitato())
.idStazione(stazione.getCodStazione())
.password(stazione.getPassword());

if(stazione.getPassword().equals("")) {
rsModel.setPassword(null);
}

if(stazione.getVersione() != null) {
switch (stazione.getVersione()) {
Expand Down Expand Up @@ -104,6 +112,10 @@ public static StazioneIndex toRsModelIndex(it.govpay.bd.model.Stazione stazione)
.domini(UriBuilderUtils.getListDomini(stazione.getCodStazione()))
.password(stazione.getPassword());

if(stazione.getPassword().equals("")) {
rsModel.setPassword(null);
}

if(stazione.getVersione() != null) {
switch (stazione.getVersione()) {
case V1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5218,13 +5218,13 @@ components:
stazionePost:
type: object
required:
- password
- abilitato
- versione
properties:
password:
type: string
description: Ragione sociale dell'intermediario PagoPA
description: >-
Password per la stazione, non necessaria nel modello unico. Resta obbligatoria per la versione = V1.
example: 123456
abilitato:
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
<input class="stazione-input-prefix" matInput placeholder="Id stazione" formControlName="idStazione_ctrl" maxlength="2" autocomplete="off" required>
</mat-form-field>
<mat-form-field class="col-12 col-md-6" color="accent" [formGroup]="fGroup">
<input matInput placeholder="Password" formControlName="password_ctrl" autocomplete="off" required>
<input matInput placeholder="Password" formControlName="password_ctrl" autocomplete="off" [required]="_isPasswordRequired">
</mat-form-field>
</div>
<div class="row position-relative">
<mat-form-field class="col-12 col-md-6" color="accent" [formGroup]="fGroup">
<mat-select placeholder="Versione" formControlName="versione_ctrl" required>
<mat-option *ngFor="let item of versioni" [value]="item.value">{{item.label}}</mat-option>
</mat-select>
</mat-form-field>
<div class="col-12 col-md-6" [formGroup]="fGroup">
<mat-slide-toggle class="mt-3" formControlName="modelloUnico_ctrl" color="accent" (change)="_modelloUnicoChange($event)">Modello unico</mat-slide-toggle>
</div>
<div class="col-12 col-md-6" [formGroup]="fGroup">
<mat-slide-toggle class="mt-3" formControlName="abilita_ctrl" color="accent">Abilitato</mat-slide-toggle>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class StazioneViewComponent implements IFormComponent, OnInit, AfterViewI
@Input() parent: any;

protected versioni: any[];
protected _isPasswordRequired: boolean = true;

constructor(public us: UtilService) {}

Expand All @@ -23,7 +24,7 @@ export class StazioneViewComponent implements IFormComponent, OnInit, AfterViewI

this.fGroup.addControl('idStazione_ctrl', new FormControl('', Validators.required));
this.fGroup.addControl('password_ctrl', new FormControl('', Validators.required));
this.fGroup.addControl('versione_ctrl', new FormControl('', Validators.required));
this.fGroup.addControl('modelloUnico_ctrl', new FormControl(false));
this.fGroup.addControl('abilita_ctrl', new FormControl(false));
}

Expand All @@ -38,8 +39,13 @@ export class StazioneViewComponent implements IFormComponent, OnInit, AfterViewI
}
this.fGroup.controls['idStazione_ctrl'].setValue((idStazione)?idStazione:'');
this.fGroup.controls['password_ctrl'].setValue((this.json.password)?this.json.password:'');
this.fGroup.controls['versione_ctrl'].setValue((this.json.password)?this.json.versione:'');
let _modelloUnicoValue = this.json.versione ? UtilService.MODELLO_UNICO_BOOLEAN_DA_VERSIONE[this.json.versione] : false;
this.fGroup.controls['modelloUnico_ctrl'].setValue(_modelloUnicoValue);
this.fGroup.controls['abilita_ctrl'].setValue((this.json.abilitato)?this.json.abilitato:false);

// controllo required campo password
this._isPasswordRequired = !_modelloUnicoValue;
this.setPasswordRequired(this._isPasswordRequired);
}
});
}
Expand All @@ -58,9 +64,24 @@ export class StazioneViewComponent implements IFormComponent, OnInit, AfterViewI
}
_json.abilitato = _info['abilita_ctrl'];
_json.password = (_info['password_ctrl'])?_info['password_ctrl']:null;
_json.versione = (_info['versione_ctrl'])?_info['versione_ctrl']:null;
let _versioneFromBoolean = UtilService.VERSIONE_DA_MODELLO_UNICO_BOOLEAN[_info['modelloUnico_ctrl']];
_json.versione = _versioneFromBoolean;
//_json.versione = (_info['versione_ctrl'])?_info['versione_ctrl']:null;

return _json;
}

protected _modelloUnicoChange(event: any) {
this._isPasswordRequired = !event.checked;
this.setPasswordRequired(this._isPasswordRequired);
}

protected setPasswordRequired(pwdRequired: boolean) {
const controls: any = this.fGroup.controls;
if (pwdRequired) {
controls.password_ctrl.setValidators(Validators.required);
} else {
controls.password_ctrl.clearValidators();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ export class RegistroIntermediariViewComponent implements IModalDialog, OnInit,
protected mapNewItem(item: any): Standard {
let _std = new Standard();
let _st = Dato.arraysToDato(
[ Voce.VERSIONE, Voce.ABILITATO ],
[ Voce.MODELLO_UNICO, Voce.ABILITATO ],
[
UtilService.defaultDisplay({ value: item.versione }),
UtilService.defaultDisplay({ value: UtilService.MODELLO_UNICO_DA_VERSIONE[item.versione] }),
UtilService.defaultDisplay({ value: UtilService.ABILITA[(item.abilitato).toString()] }) ],
', '
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,29 @@ export class UtilService {
'12': 'Agenzie Fiscali'
};

// VERSIONI STATZIONI
// VERSIONI STAZIONI
public static VERSIONI_STAZIONE: any = {
V1: 'V1',
V2: 'V2'
};

// MODELLO UNICO DA VERSIONE STAZIONE
public static MODELLO_UNICO_DA_VERSIONE: any = {
'V2': 'Si',
'V1': 'No'
};

// MODELLO UNICO BOOLEAN DA VERSIONE STAZIONE
public static MODELLO_UNICO_BOOLEAN_DA_VERSIONE: any = {
'V2': true,
'V1': false
};

// VERSIONE STAZIONE DA MODELLO UNICO BOOLEAN
public static VERSIONE_DA_MODELLO_UNICO_BOOLEAN: any = {
true: 'V2',
false: 'V1'
};

public static COOKIE_RIFIUTATI: string = 'GovPay_Dashboard_Rifiutati';
public static COOKIE_SOSPESI: string = 'GovPay_Dashboard_Sospesi';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export class Voce {
public static MODULO: string = 'Modulo interno che ha emesso l\'evento';
public static MODALITA_CONNETTORE: string = 'Modalità consegna';
public static MODELLO_PAGAMENTO: string = 'Modello pagamento';
public static MODELLO_UNICO: string = 'Modello unico';
public static MODIFICA_DOMINIO: string = 'Modifica dominio';
public static MODIFICA_ENTE_CREDITORE: string = 'Modifica Ente creditore';
public static MY_BANK: string = 'My Bank';
Expand Down

0 comments on commit 55b9cec

Please sign in to comment.