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