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