forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathddf_spec.rb
95 lines (91 loc) · 3.2 KB
/
ddf_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
RSpec.describe DDF do
let(:userid_field) do
{
:component => "text-field",
:id => "authentications.default.userid",
:name => "authentications.default.userid",
:label => _("Username"),
:helperText => _("Should have privileged access, such as root or administrator."),
:isRequired => true,
:validate => [{:type => "required"}]
}
end
let(:schema) do
{
:fields => [
{
:component => 'sub-form',
:id => 'endpoints-subform',
:name => 'endpoints-subform',
:title => _("Endpoint"),
:fields => [
{
:component => 'validate-provider-credentials',
:id => 'authentications.default.valid',
:name => 'authentications.default.valid',
:skipSubmit => true,
:validationDependencies => %w[type zone_id],
:fields => [
{
:component => "text-field",
:id => "endpoints.default.url",
:name => "endpoints.default.url",
:label => _("URL"),
:isRequired => true,
:validate => [{:type => "required"}]
},
{
:component => "select",
:id => "endpoints.default.verify_ssl",
:name => "endpoints.default.verify_ssl",
:label => _("SSL verification"),
:dataType => "integer",
:isRequired => true,
:initialValue => OpenSSL::SSL::VERIFY_PEER,
:options => [
{
:label => _('Do not verify'),
:value => OpenSSL::SSL::VERIFY_NONE,
},
{
:label => _('Verify'),
:value => OpenSSL::SSL::VERIFY_PEER,
},
]
},
userid_field,
{
:component => "password-field",
:id => "authentications.default.password",
:name => "authentications.default.password",
:label => _("Password"),
:type => "password",
:isRequired => true,
:validate => [{:type => "required"}]
},
],
},
],
},
]
}.freeze
end
it ".extract_attributes" do
expect(described_class.extract_attributes(schema, :id)).to eq %w[
endpoints-subform
authentications.default.valid
endpoints.default.url
endpoints.default.verify_ssl
authentications.default.userid
authentications.default.password
]
end
describe ".find_field" do
it "when field is found" do
expect(described_class.find_field(schema, userid_field[:id])).to equal userid_field
end
it "when field is not found" do
expect(described_class.find_field(schema, 'foo')).to be_nil
end
end
end