@@ -32,7 +32,7 @@ public class AuthTokenTest {
32
32
@ Before
33
33
public void setUp () {
34
34
System .out .println ("Running " + this .getClass ().getName () + "." + currentTest .getMethodName ());
35
- this .cloudinary = new Cloudinary ("cloudinary://a:b@test123?load_strategies=false" );
35
+ this .cloudinary = new Cloudinary ("cloudinary://a:b@test123?load_strategies=false&analytics=false " );
36
36
final AuthToken authToken = new AuthToken (KEY ).duration (300 );
37
37
authToken .startTime (11111111 ); // start time is set for test purposes
38
38
cloudinary .config .authToken = authToken ;
@@ -74,28 +74,28 @@ public void testAuthenticatedUrl() {
74
74
75
75
String message = "should add token if authToken is globally set and signed = true" ;
76
76
String url = cloudinary .url ().signed (true ).resourceType ("image" ).type ("authenticated" ).version ("1486020273" ).generate ("sample.jpg" );
77
- assertEquals (message ,"http ://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3" , url );
77
+ assertEquals (message ,"https ://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3" , url );
78
78
79
79
message = "should add token for 'public' resource" ;
80
80
url = cloudinary .url ().signed (true ).resourceType ("image" ).type ("public" ).version ("1486020273" ).generate ("sample.jpg" );
81
- assertEquals (message ,"http ://test123-res.cloudinary.com/image/public/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=c2b77d9f81be6d89b5d0ebc67b671557e88a40bcf03dd4a6997ff4b994ceb80e" , url );
81
+ assertEquals (message ,"https ://test123-res.cloudinary.com/image/public/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=c2b77d9f81be6d89b5d0ebc67b671557e88a40bcf03dd4a6997ff4b994ceb80e" , url );
82
82
83
83
message = "should not add token if signed is false" ;
84
84
url = cloudinary .url ().resourceType ("image" ).type ("authenticated" ).version ("1486020273" ).generate ("sample.jpg" );
85
- assertEquals (message ,"http ://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg" , url );
85
+ assertEquals (message ,"https ://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg" , url );
86
86
87
87
message = "should not add token if authToken is globally set but null auth token is explicitly set and signed = true" ;
88
88
url = cloudinary .url ().authToken (AuthToken .NULL_AUTH_TOKEN ).signed (true ).resourceType ("image" ).type ("authenticated" ).version ("1486020273" ).generate ("sample.jpg" );
89
- assertEquals (message ,"http ://test123-res.cloudinary.com/image/authenticated/s--v2fTPYTu--/v1486020273/sample.jpg" , url );
89
+ assertEquals (message ,"https ://test123-res.cloudinary.com/image/authenticated/s--v2fTPYTu--/v1486020273/sample.jpg" , url );
90
90
91
91
message = "explicit authToken should override global setting" ;
92
92
url = cloudinary .url ().signed (true ).authToken (new AuthToken (ALT_KEY ).startTime (222222222 ).duration (100 )).resourceType ("image" ).type ("authenticated" ).transformation (new Transformation ().crop ("scale" ).width (300 )).generate ("sample.jpg" );
93
- assertEquals (message ,"http ://test123-res.cloudinary.com/image/authenticated/c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac=55cfe516530461213fe3b3606014533b1eca8ff60aeab79d1bb84c9322eebc1f" , url );
93
+ assertEquals (message ,"https ://test123-res.cloudinary.com/image/authenticated/c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac=55cfe516530461213fe3b3606014533b1eca8ff60aeab79d1bb84c9322eebc1f" , url );
94
94
95
95
message = "should compute expiration as start time + duration" ;
96
96
url = cloudinary .url ().signed (true ).authToken (new AuthToken ().startTime (11111111 ).duration (300 ))
97
97
.type ("authenticated" ).version ("1486020273" ).generate ("sample.jpg" );
98
- assertEquals (message ,"http ://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3" , url );
98
+ assertEquals (message ,"https ://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3" , url );
99
99
100
100
}
101
101
@@ -120,7 +120,7 @@ public void testTokenGeneration(){
120
120
public void testUrlInTag () {
121
121
String message = "should add token to an image tag url" ;
122
122
String url = cloudinary .url ().signed (true ).resourceType ("image" ).type ("authenticated" ).version ("1486020273" ).imageTag ("sample.jpg" );
123
- assertThat (url , Matchers .matchesPattern ("<img.*src='http ://res.cloudinary.com/test123/image/authenticated/v1486020273/sample.jpg\\ ?__cld_token__=st=11111111~exp=11111411~hmac=9bd6f41e2a5893da8343dc8eb648de8bf73771993a6d1457d49851250caf3b80.*>" ));
123
+ assertThat (url , Matchers .matchesPattern ("<img.*src='https ://res.cloudinary.com/test123/image/authenticated/v1486020273/sample.jpg\\ ?__cld_token__=st=11111111~exp=11111411~hmac=9bd6f41e2a5893da8343dc8eb648de8bf73771993a6d1457d49851250caf3b80.*>" ));
124
124
125
125
}
126
126
0 commit comments