forked from handnot2/samly
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsamly_sp_data_test.exs
59 lines (50 loc) · 1.59 KB
/
samly_sp_data_test.exs
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
defmodule SamlySpDataTest do
use ExUnit.Case
alias Samly.SpData
@sp_config1 %{
id: "sp1",
entity_id: "urn:test:sp1",
certfile: "test/data/test.crt",
keyfile: "test/data/test.pem"
}
test "valid-sp-config-1" do
%SpData{} = sp_data = SpData.load_provider(@sp_config1)
assert sp_data.valid?
end
test "cert-unspecified-sp-config" do
sp_config = %{@sp_config1 | certfile: ""}
%SpData{cert: :undefined} = sp_data = SpData.load_provider(sp_config)
assert sp_data.valid?
end
test "key-unspecified-sp-config" do
sp_config = %{@sp_config1 | keyfile: ""}
%SpData{key: :undefined} = sp_data = SpData.load_provider(sp_config)
assert sp_data.valid?
end
test "invalid-sp-config-1" do
sp_config = %{@sp_config1 | id: ""}
%SpData{} = sp_data = SpData.load_provider(sp_config)
refute sp_data.valid?
end
test "invalid-sp-config-2" do
sp_config = %{@sp_config1 | certfile: "non-existent.crt"}
%SpData{} = sp_data = SpData.load_provider(sp_config)
refute sp_data.valid?
end
test "invalid-sp-config-3" do
sp_config = %{@sp_config1 | keyfile: "non-existent.pem"}
%SpData{} = sp_data = SpData.load_provider(sp_config)
refute sp_data.valid?
end
test "invalid-sp-config-4" do
sp_config = %{@sp_config1 | certfile: "test/data/test.pem"}
%SpData{} = sp_data = SpData.load_provider(sp_config)
refute sp_data.valid?
end
@tag :skip
test "invalid-sp-config-5" do
sp_config = %{@sp_config1 | keyfile: "test/data/test.crt"}
%SpData{} = sp_data = SpData.load_provider(sp_config)
refute sp_data.valid?
end
end