Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
parlote-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
parlote-facil
Validations
f680c4b7
Valider
f680c4b7
rédigé
il y a 14 ans
par
Raphael
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
RS, IZ; Signature Verification now stubbed out outside of encryption specs, green
parent
4a0bd5fc
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
Aucune requête de fusion associée trouvée
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
app/models/post.rb
+1
-1
1 ajout, 1 suppression
app/models/post.rb
spec/spec_helper.rb
+15
-2
15 ajouts, 2 suppressions
spec/spec_helper.rb
spec/user_encryption_spec.rb
+5
-5
5 ajouts, 5 suppressions
spec/user_encryption_spec.rb
avec
21 ajouts
et
8 suppressions
app/models/post.rb
+
1
−
1
Voir le fichier @
f680c4b7
...
@@ -46,7 +46,7 @@ class Post
...
@@ -46,7 +46,7 @@ class Post
#ENCRYPTION
#ENCRYPTION
before_validation
:sign_if_mine
before_validation
:sign_if_mine
#
validates_true_for :owner_signature, :logic => lambda {self.verify_signature}
validates_true_for
:owner_signature
,
:logic
=>
lambda
{
self
.
verify_signature
}
key
:owner_signature
,
String
key
:owner_signature
,
String
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/spec_helper.rb
+
15
−
2
Voir le fichier @
f680c4b7
...
@@ -12,7 +12,7 @@ include Devise::TestHelpers
...
@@ -12,7 +12,7 @@ include Devise::TestHelpers
Dir
[
"
#{
File
.
dirname
(
__FILE__
)
}
/support/**/*.rb"
].
each
{
|
f
|
require
f
}
Dir
[
"
#{
File
.
dirname
(
__FILE__
)
}
/support/**/*.rb"
].
each
{
|
f
|
require
f
}
RSpec
.
configure
do
|
config
|
RSpec
.
configure
do
|
config
|
config
.
mock_with
:mocha
config
.
mock_with
:rspec
config
.
mock_with
:rspec
DatabaseCleaner
.
strategy
=
:truncation
DatabaseCleaner
.
strategy
=
:truncation
...
@@ -20,11 +20,12 @@ RSpec.configure do |config|
...
@@ -20,11 +20,12 @@ RSpec.configure do |config|
config
.
before
(
:suite
)
do
config
.
before
(
:suite
)
do
DatabaseCleaner
.
clean_with
(
:truncation
)
DatabaseCleaner
.
clean_with
(
:truncation
)
stub_signature_verification
end
end
config
.
before
(
:each
)
do
config
.
before
(
:each
)
do
DatabaseCleaner
.
start
DatabaseCleaner
.
start
stub_sockets_controller
stub_sockets_controller
end
end
config
.
after
(
:each
)
do
config
.
after
(
:each
)
do
...
@@ -39,3 +40,15 @@ end
...
@@ -39,3 +40,15 @@ end
mock_sockets_controller
.
stub!
(
:delete_subscriber
).
and_return
(
true
)
mock_sockets_controller
.
stub!
(
:delete_subscriber
).
and_return
(
true
)
SocketsController
.
stub!
(
:new
).
and_return
(
mock_sockets_controller
)
SocketsController
.
stub!
(
:new
).
and_return
(
mock_sockets_controller
)
end
end
def
stub_signature_verification
Post
.
any_instance
.
stubs
(
:verify_signature
).
returns
(
true
)
StatusMessage
.
any_instance
.
stubs
(
:verify_signature
).
returns
(
true
)
Blog
.
any_instance
.
stubs
(
:verify_signature
).
returns
(
true
)
Bookmark
.
any_instance
.
stubs
(
:verify_signature
).
returns
(
true
)
end
def
unstub_mocha_stubs
Mocha
::
Mockery
.
instance
.
stubba
.
unstub_all
end
Ce diff est replié.
Cliquez pour l'agrandir.
spec/user_encryption_spec.rb
+
5
−
5
Voir le fichier @
f680c4b7
...
@@ -9,6 +9,7 @@ describe 'user encryption' do
...
@@ -9,6 +9,7 @@ describe 'user encryption' do
end
end
before
do
before
do
unstub_mocha_stubs
@u
=
Factory
.
create
(
:user
)
@u
=
Factory
.
create
(
:user
)
@u
.
send
(
:assign_key
)
@u
.
send
(
:assign_key
)
@u
.
save
@u
.
save
...
@@ -22,12 +23,13 @@ describe 'user encryption' do
...
@@ -22,12 +23,13 @@ describe 'user encryption' do
end
end
# after :all do
after
do
stub_signature_verification
#gpgdir = File.expand_path("../../db/gpg-#{Rails.env}", __FILE__)
#gpgdir = File.expand_path("../../db/gpg-#{Rails.env}", __FILE__)
#ctx = GPGME::Ctx.new
#ctx = GPGME::Ctx.new
#keys = ctx.keys
#keys = ctx.keys
#keys.each{|k| ctx.delete_key(k, true)}
#keys.each{|k| ctx.delete_key(k, true)}
#
end
end
it
'should remove the key from the keyring on person destroy'
do
it
'should remove the key from the keyring on person destroy'
do
pending
"We can implement deleting from the keyring later, its annoying to test b/c no stub any instance of"
pending
"We can implement deleting from the keyring later, its annoying to test b/c no stub any instance of"
...
@@ -79,9 +81,9 @@ describe 'user encryption' do
...
@@ -79,9 +81,9 @@ describe 'user encryption' do
end
end
describe
'signing and verifying'
do
describe
'signing and verifying'
do
it
'should sign a message on create'
do
it
'should sign a message on create'
do
message
=
Factory
.
create
(
:status_message
,
:person
=>
@u
)
message
=
Factory
.
create
(
:status_message
,
:person
=>
@u
)
puts
message
.
owner_signature
message
.
verify_signature
.
should
be
true
message
.
verify_signature
.
should
be
true
end
end
...
@@ -126,8 +128,6 @@ describe 'user encryption' do
...
@@ -126,8 +128,6 @@ describe 'user encryption' do
xml
.
include?
(
message
.
owner_signature
).
should
be
true
xml
.
include?
(
message
.
owner_signature
).
should
be
true
end
end
it
'the signature should be verified on marshaling'
do
it
'the signature should be verified on marshaling'
do
pending
"We're going to work on embeded profile"
message
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
message
=
Factory
.
build
(
:status_message
,
:person
=>
@person
)
message
.
owner_signature
=
GPGME
.
sign
(
message
.
signable_string
,
nil
,
message
.
owner_signature
=
GPGME
.
sign
(
message
.
signable_string
,
nil
,
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@u
.
key
]})
{
:mode
=>
GPGME
::
SIG_MODE_DETACH
,
:armor
=>
true
,
:signers
=>
[
@u
.
key
]})
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter