| @@ 114-133 (lines=20) @@ | ||
| 111 | ); |
|
| 112 | } |
|
| 113 | ||
| 114 | public function testSetTotpSecret() |
|
| 115 | { |
|
| 116 | $otp = new Otp(); |
|
| 117 | $totpSecret = 'MM7TTLHPA7WZOJFB'; |
|
| 118 | $totpKey = $otp->totp(Base32::decode($totpSecret)); |
|
| 119 | ||
| 120 | $this->assertTrue( |
|
| 121 | $this->makeRequest( |
|
| 122 | ['vpn-user-portal', 'aabbcc'], |
|
| 123 | 'POST', |
|
| 124 | 'set_totp_secret', |
|
| 125 | [], |
|
| 126 | [ |
|
| 127 | 'user_id' => 'foo', |
|
| 128 | 'totp_secret' => $totpSecret, |
|
| 129 | 'totp_key' => $totpKey, |
|
| 130 | ] |
|
| 131 | ) |
|
| 132 | ); |
|
| 133 | } |
|
| 134 | ||
| 135 | public function testVerifyOtpKey() |
|
| 136 | { |
|
| @@ 135-153 (lines=19) @@ | ||
| 132 | ); |
|
| 133 | } |
|
| 134 | ||
| 135 | public function testVerifyOtpKey() |
|
| 136 | { |
|
| 137 | $otp = new Otp(); |
|
| 138 | $totpSecret = 'CN2XAL23SIFTDFXZ'; |
|
| 139 | $totpKey = $otp->totp(Base32::decode($totpSecret)); |
|
| 140 | ||
| 141 | $this->assertTrue( |
|
| 142 | $this->makeRequest( |
|
| 143 | ['vpn-user-portal', 'aabbcc'], |
|
| 144 | 'POST', |
|
| 145 | 'verify_totp_key', |
|
| 146 | [], |
|
| 147 | [ |
|
| 148 | 'user_id' => 'bar', |
|
| 149 | 'totp_key' => $totpKey, |
|
| 150 | ] |
|
| 151 | ) |
|
| 152 | ); |
|
| 153 | } |
|
| 154 | ||
| 155 | public function testVerifyOtpKeyWrong() |
|
| 156 | { |
|