@@ -49,6 +49,10 @@ var testCreateResource = []struct {
4949 expect string
5050 errPrefix string
5151}{
52+ {
53+ "https" , "https://example.com/a?b=1&c=2" ,
54+ "https://example.com/a?b=1&c=2" , "" ,
55+ },
5256 {
5357 "https" , "https://example.com/a?b=1" ,
5458 "https://example.com/a?b=1" , "" ,
@@ -61,6 +65,10 @@ var testCreateResource = []struct {
6165 "rtmp" , "https://example.com/a?b=1" ,
6266 "a?b=1" , "" ,
6367 },
68+ {
69+ "rtmp" , "https://example.com/a?b=1&c=2" ,
70+ "a?b=1&c=2" , "" ,
71+ },
6472 {
6573 "ftp" , "ftp://example.com/a?b=1" ,
6674 "" , "invalid URL scheme" ,
@@ -112,6 +120,27 @@ func TestEncodePolicy(t *testing.T) {
112120 }
113121}
114122
123+ func TestEncodePolicyWithQueryParams (t * testing.T ) {
124+ const (
125+ expectedJSONPolicy = `{"Statement":[{"Resource":"https://example.com/a?b=1&c=2","Condition":{"DateLessThan":{"AWS:EpochTime":1257894000}}}]}`
126+ expectedB64Policy = `eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9hP2I9MSZjPTIiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjEyNTc4OTQwMDB9fX1dfQ==`
127+ )
128+ p := NewCannedPolicy ("https://example.com/a?b=1&c=2" , testTime )
129+
130+ b64Policy , jsonPolicy , err := encodePolicy (p )
131+ if err != nil {
132+ t .Fatalf ("Unexpected error, %#v" , err )
133+ }
134+
135+ if string (jsonPolicy ) != expectedJSONPolicy {
136+ t .Errorf ("Expected json encoding to match, \n expect: %s\n actual: %s\n " , expectedJSONPolicy , jsonPolicy )
137+ }
138+
139+ if string (b64Policy ) != expectedB64Policy {
140+ t .Errorf ("Expected b64 encoding to match, \n expect: %s\n actual: %s\n " , expectedB64Policy , b64Policy )
141+ }
142+ }
143+
115144func TestSignEncodedPolicy (t * testing.T ) {
116145 p := NewCannedPolicy ("https://example.com/a" , testTime )
117146 _ , jsonPolicy , err := encodePolicy (p )
0 commit comments