Add account creation service
This commit is contained in:
33
spec/services/create_account_spec.rb
Normal file
33
spec/services/create_account_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CreateAccount, type: :model do
|
||||
let(:ldap_client_mock) { instance_double(Net::LDAP) }
|
||||
|
||||
before do
|
||||
allow(service).to receive(:ldap_client).and_return(ldap_client_mock)
|
||||
end
|
||||
|
||||
describe "#add_ldap_document" do
|
||||
let(:service) { CreateAccount.new(
|
||||
username: 'halfinney',
|
||||
email: 'halfinney@example.com',
|
||||
password: 'remember-remember-the-5th-of-november'
|
||||
)}
|
||||
|
||||
it "creates a new document with the correct attributes" do
|
||||
expect(ldap_client_mock).to receive(:add).with(
|
||||
dn: "cn=halfinney,ou=kosmos.org,cn=users,dc=kosmos,dc=org",
|
||||
attributes: {
|
||||
objectclass: ["top", "account", "person", "extensibleObject"],
|
||||
cn: "halfinney",
|
||||
sn: "halfinney",
|
||||
uid: "halfinney",
|
||||
mail: "halfinney@example.com",
|
||||
userPassword: /^{SSHA512}.{171}=/
|
||||
}
|
||||
)
|
||||
|
||||
service.send(:add_ldap_document)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user