KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_oauth_pkce.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21
22#include <oauth/oauth_pkce.h>
23
24
25BOOST_AUTO_TEST_SUITE( OAuthPkceTests )
26
27BOOST_AUTO_TEST_CASE( Rfc7636ChallengeExampleMatches )
28{
29 const wxString verifier = wxS( "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk" );
30 const wxString challenge = OAUTH_PKCE::CreateCodeChallenge( verifier );
31
32 BOOST_CHECK_EQUAL( challenge, wxString( "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM" ) );
33}
34
35BOOST_AUTO_TEST_CASE( GeneratedVerifierAndStateLookValid )
36{
37 const wxString verifier = OAUTH_PKCE::GenerateCodeVerifier();
38 const wxString state = OAUTH_PKCE::GenerateState();
39
40 BOOST_CHECK_GE( verifier.Length(), 43 );
41 BOOST_CHECK_LE( verifier.Length(), 128 );
42 BOOST_CHECK( verifier.find_first_not_of(
43 wxS( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~" ) )
44 == wxString::npos );
45 BOOST_CHECK_GE( state.Length(), 32 );
46 BOOST_CHECK( !OAUTH_PKCE::CreateCodeChallenge( verifier ).IsEmpty() );
47}
48
static wxString CreateCodeChallenge(const wxString &aVerifier)
static wxString GenerateCodeVerifier()
static wxString GenerateState()
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(Rfc7636ChallengeExampleMatches)
BOOST_CHECK_EQUAL(result, "25.4")