I’m developing a REST API where one endpoint is used to create accounts, including a passwordHash field (currently unencrypted). For security reasons, when fetching account details via a GET method, I’ve configured my Account entity as follows:
public class Account {
// Other fields
@Column(name = "password_hash", nullable = false)
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String passwordHash;
}
The passwordHash field is marked with @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) to exclude it from JSON serialization during GET requests.
However, during integration testing using ModelMapper to convert Account objects to JSON, the passwordHash field is omitted, causing failures due to null values being interpreted. What adjustments should I make or what alternative approach can I consider to handle this situation effectively?