@@ -31,6 +31,78 @@ protected function finalize()
3131 AlibabaCloud::cancelMock ();
3232 }
3333
34+ /**
35+ * @throws ClientException
36+ */
37+ public function testAccessKeyIdEmpty ()
38+ {
39+ $ this ->expectException (ClientException::class);
40+ $ this ->expectExceptionMessage ('AccessKey ID cannot be empty ' );
41+ // Setup
42+ $ client = new RamRoleArnClient (
43+ '' ,
44+ 'access_key_secret ' ,
45+ 'role_arn ' ,
46+ 'role_session_name '
47+ );
48+ $ provider = new RamRoleArnProvider ($ client );
49+ $ provider ->get ();
50+ }
51+
52+ /**
53+ * @throws ClientException
54+ */
55+ public function testAccessKeyIdFormat ()
56+ {
57+ $ this ->expectException (ClientException::class);
58+ $ this ->expectExceptionMessage ('AccessKey ID must be a string ' );
59+ // Setup
60+ $ client = new RamRoleArnClient (
61+ null ,
62+ 'access_key_secret ' ,
63+ 'role_arn ' ,
64+ 'role_session_name '
65+ );
66+ $ provider = new RamRoleArnProvider ($ client );
67+ $ provider ->get ();
68+ }
69+
70+ /**
71+ * @throws ClientException
72+ */
73+ public function testAccessKeySecretEmpty ()
74+ {
75+ $ this ->expectException (ClientException::class);
76+ $ this ->expectExceptionMessage ('AccessKey Secret cannot be empty ' );
77+ // Setup
78+ $ client = new RamRoleArnClient (
79+ 'access_key_id ' ,
80+ '' ,
81+ 'role_arn ' ,
82+ 'role_session_name '
83+ );
84+ $ provider = new RamRoleArnProvider ($ client );
85+ $ provider ->get ();
86+ }
87+
88+ /**
89+ * @throws ClientException
90+ */
91+ public function testAccessKeySecretFormat ()
92+ {
93+ $ this ->expectException (ClientException::class);
94+ $ this ->expectExceptionMessage ('AccessKey Secret must be a string ' );
95+ // Setup
96+ $ client = new RamRoleArnClient (
97+ 'access_key_id ' ,
98+ null ,
99+ 'role_arn ' ,
100+ 'role_session_name '
101+ );
102+ $ provider = new RamRoleArnProvider ($ client );
103+ $ provider ->get ();
104+ }
105+
34106 /**
35107 * @throws ClientException
36108 */
@@ -54,7 +126,6 @@ public function testGet()
54126 } catch (ServerException $ e ) {
55127 self ::assertEquals ('InvalidAccessKeyId.NotFound ' , $ e ->getErrorCode ());
56128 }
57-
58129 }
59130
60131 /**
@@ -91,7 +162,6 @@ public function testGetInCache()
91162
92163 // Assert
93164 self ::assertInstanceOf (StsCredential::class, $ actual );
94-
95165 }
96166
97167 /**
@@ -108,7 +178,6 @@ public function testNoCredentials()
108178
109179 $ provider = new RamRoleArnProvider ($ client );
110180 $ provider ->get ();
111-
112181 }
113182
114183 /**
@@ -140,7 +209,5 @@ public function testOk()
140209 $ provider = new RamRoleArnProvider ($ client );
141210 $ credential = $ provider ->get ();
142211 self ::assertInstanceOf (StsCredential::class, $ credential );
143-
144212 }
145-
146213}
0 commit comments