@@ -30,19 +30,30 @@ final class UrlBuilderTest extends TestCase
3030{
3131 public function testBuildUrl (): void
3232 {
33- $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' );
33+ // Test with sha1 hash algorithm
34+ $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' , 'sha1 ' );
3435
3536 // echo sha1('getMeetings' . 'foo=bar&baz=bazinga' . 'AFFE');
3637 $ this ->assertSame (
3738 'https://bbb.example/bigbluebutton/api/getMeetings?foo=bar&baz=bazinga&checksum=8c313ec566a91bb9a409b51a0f515f53216a43ae ' ,
3839 $ urlBuilder ->buildUrl ('getMeetings ' , 'foo=bar&baz=bazinga ' ),
3940 'signed URL is OK '
4041 );
42+
43+ // Test with sha256 hash algorithm
44+ $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' , 'sha256 ' );
45+
46+ // echo hash('sha256', 'getMeetings' . 'foo=bar&baz=bazinga' . 'AFFE');
47+ $ this ->assertSame (
48+ 'https://bbb.example/bigbluebutton/api/getMeetings?foo=bar&baz=bazinga&checksum=e93a022a742425259bf3acec803ad8b4e428e7653b66bfecfa60d935a04bcc3b ' ,
49+ $ urlBuilder ->buildUrl ('getMeetings ' , 'foo=bar&baz=bazinga ' ),
50+ 'signed URL is OK '
51+ );
4152 }
4253
4354 public function testBuildUrlWithEmptyParams (): void
4455 {
45- $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' );
56+ $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' , ' sha1 ' );
4657
4758 // echo sha1('getMeetings' . '' . 'AFFE');
4859 $ this ->assertSame (
@@ -54,7 +65,7 @@ public function testBuildUrlWithEmptyParams(): void
5465
5566 public function testBuildUrlWithoutAppend (): void
5667 {
57- $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' );
68+ $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' , ' sha1 ' );
5869
5970 $ this ->assertSame (
6071 'https://bbb.example/bigbluebutton/api/getMeetings ' ,
@@ -65,7 +76,7 @@ public function testBuildUrlWithoutAppend(): void
6576
6677 public function testBuildQs (): void
6778 {
68- $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' );
79+ $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' , ' sha1 ' );
6980
7081 // echo sha1('getMeetings' . 'foo=bar&baz=bazinga' . 'AFFE');
7182 $ this ->assertSame (
@@ -77,7 +88,7 @@ public function testBuildQs(): void
7788
7889 public function testBuildQsWithEmptyParams (): void
7990 {
80- $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' );
91+ $ urlBuilder = new UrlBuilder ('AFFE ' , 'https://bbb.example/bigbluebutton/ ' , ' sha1 ' );
8192
8293 // echo sha1('getMeetings' . '' . 'AFFE');
8394 $ this ->assertSame (
0 commit comments