forked from internetee/registry
-
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.
- Loading branch information
Showing
9 changed files
with
154 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class CertificateVersion < PaperTrail::Version | ||
self.table_name = :log_certificates | ||
self.sequence_name = :log_certificates_id_seq | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# default fabricator should be reusable | ||
Fabricator(:certificate) do | ||
api_user | ||
csr "-----BEGIN CERTIFICATE REQUEST-----\n" \ | ||
"MIIE+DCCAuACAQAwgZ0xCzAJBgNVBAYTAkVFMREwDwYDVQQIDAhIYXJqdW1hYTEQ\n" \ | ||
"MA4G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GCSqGSIb3DQEBCwUAA4ICAQAkTlU3\n" \ | ||
"RcI6UMRA7As2FJSph3QurPebQFoZhnhMD+hb6+hXip8MY77YxLwo/ihB9wghaZKL\n" \ | ||
"uV0BxjdZgjDt9GhA8dtPgaCp5LvB6kQYvcEzRvitN2CpJhtz39rlF3gxuy+RtpNf\n" \ | ||
"5KbC691FivoXur1qx9I7mc4snB3DTzLiJPIZ6nQzPYcSVpPCbns30N/i/sOdHO0o\n" \ | ||
"9hP5wlhCdYrOxad993m+InpMDyDWhB1+TA9ZO7gYpg8S4kBX3Cz9OXe80Pe56ZdK\n" \ | ||
"pcgjTXnUDjNSRRGamJib2lyZ/axMbb/etwyy3X+jBDuOQropkmgrPEFJHpgNlFah\n" \ | ||
"BuW7KEASqbw5YxpTSc0nDk5uxBw3voL8fk9M1sX64tbzGAEBRZnrWGeb1mOLM/YI\n" \ | ||
"K6ocAYSBhNmWUzpHTwL7qSeP9ztQUGzoGHyRjBdan+1U2G75Kpj+TjEm/X8wmtnq\n" \ | ||
"3/qVhUYNEavcZbgR1gSE45+mS8NsD7Oq0Xdc0UKsVDbUcCGIkGG9+ERAbRznfi3W\n" \ | ||
"qhChtUxySX8T3SmX5mviwlJ5OwQVjdUF1/2voPK0oFK7zV+wZqcuORzDKdqB8XV7\n" \ | ||
"MDcQjza4EOB78OmcHDgQ7nMXuY7/UL4F+bRZosxPy43X2JId5d+/GpgV8sP9dzK8\n" \ | ||
"UGJDNEZ2YsBbPuKZS+2eNZ8g3sjjFBeadvrQ1w==\n" \ | ||
"-----END CERTIFICATE REQUEST-----" | ||
end |
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,61 @@ | ||
require 'rails_helper' | ||
|
||
describe Certificate do | ||
it { should belong_to(:api_user) } | ||
|
||
context 'with invalid attribute' do | ||
before :all do | ||
@certificate = Certificate.new | ||
end | ||
|
||
it 'should not be valid' do | ||
@certificate.valid? | ||
@certificate.errors.full_messages.should match_array([ | ||
"Csr is missing" | ||
]) | ||
end | ||
|
||
it 'should not have any versions' do | ||
@certificate.versions.should == [] | ||
end | ||
end | ||
|
||
context 'with valid attributes' do | ||
before :all do | ||
@certificate = Fabricate(:certificate) | ||
end | ||
|
||
it 'should be valid' do | ||
@certificate.valid? | ||
@certificate.errors.full_messages.should match_array([]) | ||
end | ||
|
||
it 'should be valid twice' do | ||
@certificate = Fabricate(:certificate) | ||
@certificate.valid? | ||
@certificate.errors.full_messages.should match_array([]) | ||
end | ||
|
||
it 'should sign csr' do | ||
@certificate.status.should == 'unsigned' | ||
@certificate.sign! | ||
@certificate.status.should == 'signed' | ||
@certificate.crt.should_not be_blank | ||
end | ||
|
||
it 'should revoke crt' do | ||
@certificate.revoke! | ||
@certificate.status.should == 'revoked' | ||
end | ||
|
||
it 'should have one version' do | ||
with_versioning do | ||
@certificate.versions.should == [] | ||
@certificate.csr = 'new_request' | ||
@certificate.save | ||
@certificate.errors.full_messages.should match_array([]) | ||
@certificate.versions.size.should == 1 | ||
end | ||
end | ||
end | ||
end |