- it "should return a hashed password" do
- result = scope.function_pw_hash(['password', 'sha-512', 'salt'])
- expect(result).to eql('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.')
- end
-
- it "should use the specified salt" do
- result = scope.function_pw_hash(['password', 'sha-512', 'salt'])
- expect(result).to match('salt')
- end
-
- it "should use the specified hash type" do
- resultmd5 = scope.function_pw_hash(['password', 'md5', 'salt'])
- resultsha256 = scope.function_pw_hash(['password', 'sha-256', 'salt'])
- resultsha512 = scope.function_pw_hash(['password', 'sha-512', 'salt'])
-
- expect(resultmd5).to eql('$1$salt$qJH7.N4xYta3aEG/dfqo/0')
- expect(resultsha256).to eql('$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1')
- expect(resultsha512).to eql('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.')
- end
-
- it "should generate a valid hash" do
- password_hash = scope.function_pw_hash(['password', 'sha-512', 'salt'])
-
- hash_parts = password_hash.match(%r{\A\$(.*)\$([a-zA-Z0-9./]+)\$([a-zA-Z0-9./]+)\z})
+ it { is_expected.to run.with_params('password', 'md5', 'salt').and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') }
+ it { is_expected.to run.with_params('password', 'sha-256', 'salt').and_return('$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1') }
+ it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_return('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.') }
+ end