Commit bf5a32f8 authored by o's avatar o
Browse files

add some tests for whois api

parent 8c02e33c
Pipeline #9215 passed with stage
in 3 minutes and 19 seconds
......@@ -180,4 +180,38 @@ describe "iApi users admin route" do
end
end
end
context '/whois' do
it 'queries users' do
get_as('admin', '/users_admin/whois', search: 'user1@example.com')
expect(last_response.parsed_body["matches"].size).to eq(1)
expect(last_response.parsed_body["matches"][0]["email_object"]).to eq("EmailUser")
get_as('admin', '/users_admin/whois', search: 'user1@')
expect(last_response.parsed_body["matches"].size).to eq(1)
expect(last_response.parsed_body["matches"][0]["email"]).to eq("user1@example.com")
expect(last_response.parsed_body["matches"][0]["email_object"]).to eq("EmailUser")
end
it 'queries forwards' do
get_as('admin', '/users_admin/whois', search: 'fwd3@')
expect(last_response.parsed_body["matches"].size).to eq(1)
expect(last_response.parsed_body["matches"][0]["email_object"]).to eq("EmailAlias")
expect(last_response.parsed_body["matches"][0]["resource"]).to eq("mail_alias")
expect(last_response.parsed_body["matches"][0]["forwards"]).to eq(["user1@example.com"])
get_as('admin', '/users_admin/whois', search: 'fwd5@')
expect(last_response.parsed_body["matches"].size).to eq(1)
expect(last_response.parsed_body["matches"][0]["email_object"]).to be_nil
expect(last_response.parsed_body["matches"][0]["forwards"]).to eq(["external@test.com"])
end
it 'queries resources' do
u = EmailUser.active.all.sample
ResourceManager.create!(
"schleuder",
u.email,
{name: "testcreation",
domain: "example.com",
schleuder_host: "schleuder1"})
get_as('admin', '/users_admin/whois', search: 'testcreation@example.com')
expect(last_response.parsed_body["matches"].size).to eq(1)
expect(last_response.parsed_body["matches"][0]["resource"]).to eq("schleuder")
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment