@@ -15,65 +15,105 @@ func TestNewServer(t *testing.T) {
1515 {
1616 name : "happy path" ,
1717 flags : & flags {
18- hmacKey : "SuperSecretKey123!" ,
19- upstreamURL : "http://localhost:8080 " ,
18+ signingKey : "SuperSecretKey123!" ,
19+ signingMethod : "HMAC " ,
2020 },
2121 cfgContent : "claimPolicies: {}\n routePolicies: []" ,
2222 wantErr : false ,
2323 },
2424 {
2525 name : "no config" ,
2626 flags : & flags {
27- hmacKey : "SuperSecretKey123!" ,
28- upstreamURL : "http://localhost:8080 " ,
27+ signingKey : "SuperSecretKey123!" ,
28+ signingMethod : "HMAC " ,
2929 },
3030 cfgContent : "" ,
3131 wantErr : true ,
3232 },
3333 {
34- name : "auth server without proxy" ,
34+ name : "reverse proxy" ,
3535 flags : & flags {
36- hmacKey : "SuperSecretKey123!" ,
36+ signingKey : "SuperSecretKey123!" ,
37+ signingMethod : "HMAC" ,
38+ upstreamURL : "http://localhost:8080" ,
39+ },
40+ cfgContent : "claimPolicies: {}\n routePolicies: []" ,
41+ wantErr : false ,
42+ },
43+ {
44+ name : "clock skewed" ,
45+ flags : & flags {
46+ signingKey : "SuperSecretKey123!" ,
47+ signingMethod : "HMAC" ,
48+ clockSkew : "10" ,
3749 },
3850 cfgContent : "claimPolicies: {}\n routePolicies: []" ,
3951 wantErr : false ,
4052 },
4153 {
4254 name : "invalid url scheme" ,
4355 flags : & flags {
44- hmacKey : "SuperSecretKey123!" ,
45- upstreamURL : "tcp://localhost:8080" ,
56+ signingKey : "SuperSecretKey123!" ,
57+ signingMethod : "HMAC" ,
58+ upstreamURL : "tcp://localhost:8080" ,
4659 },
4760 cfgContent : "claimPolicies: {}\n routePolicies: []" ,
4861 wantErr : true ,
4962 },
5063 {
5164 name : "malformed url" ,
5265 flags : & flags {
53- hmacKey : "SuperSecretKey123!" ,
54- upstreamURL : "!!http://localhost:8080" ,
66+ signingKey : "SuperSecretKey123!" ,
67+ signingMethod : "HMAC" ,
68+ upstreamURL : "!!http://localhost:8080" ,
5569 },
5670 cfgContent : "claimPolicies: {}\n routePolicies: []" ,
5771 wantErr : true ,
5872 },
5973 {
6074 name : "invalid config yaml" ,
6175 flags : & flags {
62- hmacKey : "SuperSecretKey123!" ,
63- upstreamURL : "http://localhost:8080 " ,
76+ signingKey : "SuperSecretKey123!" ,
77+ signingMethod : "HMAC " ,
6478 },
6579 cfgContent : ": invalid" ,
6680 wantErr : true ,
6781 },
6882 {
6983 name : "invalid config content" ,
7084 flags : & flags {
71- hmacKey : "SuperSecretKey123!" ,
72- upstreamURL : "http://localhost:8080 " ,
85+ signingKey : "SuperSecretKey123!" ,
86+ signingMethod : "HMAC " ,
7387 },
7488 cfgContent : "claimPolicies:\n PolicyWithoutClaim:\n - value: test\n routePolicies: []" ,
7589 wantErr : true ,
7690 },
91+ {
92+ name : "no signing key" ,
93+ flags : & flags {
94+ signingMethod : "HMAC" ,
95+ },
96+ cfgContent : "claimPolicies: {}\n routePolicies: []" ,
97+ wantErr : true ,
98+ },
99+ {
100+ name : "no signing method" ,
101+ flags : & flags {
102+ signingKey : "SuperSecretKey123!" ,
103+ },
104+ cfgContent : "claimPolicies: {}\n routePolicies: []" ,
105+ wantErr : true ,
106+ },
107+ {
108+ name : "invalid clock skew flag" ,
109+ flags : & flags {
110+ signingKey : "SuperSecretKey123!" ,
111+ signingMethod : "HMAC" ,
112+ clockSkew : "not a number" ,
113+ },
114+ cfgContent : "claimPolicies: {}\n routePolicies: []" ,
115+ wantErr : true ,
116+ },
77117 }
78118 for _ , tt := range tests {
79119 t .Run (tt .name , func (t * testing.T ) {
0 commit comments