spec/models/identity_provider_spec.rb in osso-0.0.3.26 vs spec/models/identity_provider_spec.rb in osso-0.0.3.27

- old
+ new

@@ -33,6 +33,27 @@ idp_sso_target_url: subject.sso_url, issuer: subject.domain, ) end end + + describe '#validate_sso_cert' do + it 'rejects an invalid cert' do + subject.update(sso_cert: 'bad-cert') + + expect(subject.errors.full_messages.first).to include('x509 Certificate is malformed') + end + + it 'massages a cert with header and footer' do + subject.update(sso_cert: valid_x509_pem) + + expect(subject.errors).to be_empty + expect(subject.sso_cert).to_not include('BEGIN CERTIFICATE') + end + + it 'accepts a cert without header and footer' do + subject.update(sso_cert: raw_x509_string) + + expect(subject.errors).to be_empty + end + end end