Make location optional

Remove form validation and default value in input schema
This commit is contained in:
sayali 2020-10-07 13:31:23 -07:00
parent c72661a87f
commit b7d0e62844
5 changed files with 7 additions and 13 deletions

View File

@ -43,9 +43,7 @@ class AuthorityInputSchema(LemurInputSchema):
organization = fields.String( organization = fields.String(
missing=lambda: current_app.config.get("LEMUR_DEFAULT_ORGANIZATION") missing=lambda: current_app.config.get("LEMUR_DEFAULT_ORGANIZATION")
) )
location = fields.String( location = fields.String()
missing=lambda: current_app.config.get("LEMUR_DEFAULT_LOCATION")
)
country = fields.String( country = fields.String(
missing=lambda: current_app.config.get("LEMUR_DEFAULT_COUNTRY") missing=lambda: current_app.config.get("LEMUR_DEFAULT_COUNTRY")
) )

View File

@ -107,9 +107,7 @@ class CertificateInputSchema(CertificateCreationSchema):
organization = fields.String( organization = fields.String(
missing=lambda: current_app.config.get("LEMUR_DEFAULT_ORGANIZATION") missing=lambda: current_app.config.get("LEMUR_DEFAULT_ORGANIZATION")
) )
location = fields.String( location = fields.String()
missing=lambda: current_app.config.get("LEMUR_DEFAULT_LOCATION")
)
country = fields.String( country = fields.String(
missing=lambda: current_app.config.get("LEMUR_DEFAULT_COUNTRY") missing=lambda: current_app.config.get("LEMUR_DEFAULT_COUNTRY")
) )

View File

@ -26,8 +26,7 @@
Location Location
</label> </label>
<div class="col-sm-10"> <div class="col-sm-10">
<input name="location" ng-model="authority.location" placeholder="Location" class="form-control" required/> <input name="location" ng-model="authority.location" placeholder="Location" class="form-control"/>
<p ng-show="dnForm.location.$invalid && !dnForm.location.$pristine" class="help-block">You must enter a location</p>
</div> </div>
</div> </div>
<div class="form-group" <div class="form-group"

View File

@ -38,9 +38,7 @@
Location Location
</label> </label>
<div class="col-sm-10"> <div class="col-sm-10">
<input name="location" ng-model="certificate.location" placeholder="Location" class="form-control" required/> <input name="location" ng-model="certificate.location" placeholder="Location" class="form-control"/>
<p ng-show="dnForm.location.$invalid && !dnForm.location.$pristine" class="help-block">You must enter a
location</p>
</div> </div>
</div> </div>
<div class="form-group" <div class="form-group"

View File

@ -154,7 +154,7 @@ def test_get_certificate_primitives(certificate):
with freeze_time(datetime.date(year=2016, month=10, day=30)): with freeze_time(datetime.date(year=2016, month=10, day=30)):
primitives = get_certificate_primitives(certificate) primitives = get_certificate_primitives(certificate)
assert len(primitives) == 26 assert len(primitives) == 25
assert (primitives["key_type"] == "RSA2048") assert (primitives["key_type"] == "RSA2048")
@ -254,17 +254,18 @@ def test_certificate_input_schema(client, authority):
"validityStart": arrow.get(2018, 11, 9).isoformat(), "validityStart": arrow.get(2018, 11, 9).isoformat(),
"validityEnd": arrow.get(2019, 11, 9).isoformat(), "validityEnd": arrow.get(2019, 11, 9).isoformat(),
"dnsProvider": None, "dnsProvider": None,
"location": "A Place"
} }
data, errors = CertificateInputSchema().load(input_data) data, errors = CertificateInputSchema().load(input_data)
assert not errors assert not errors
assert data["authority"].id == authority.id assert data["authority"].id == authority.id
assert data["location"] == "A Place"
# make sure the defaults got set # make sure the defaults got set
assert data["common_name"] == "test.example.com" assert data["common_name"] == "test.example.com"
assert data["country"] == "US" assert data["country"] == "US"
assert data["location"] == "Los Gatos"
assert len(data.keys()) == 19 assert len(data.keys()) == 19