本文整理汇总了C++中TST_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ TST_ASSERT函数的具体用法?C++ TST_ASSERT怎么用?C++ TST_ASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TST_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TST_ASSERT_ERR
static char *test_jwt_get_string(apr_pool_t *pool) {
//apr_jwt_get_string
const char *s =
"eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9"
".eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ"
".dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk";
apr_jwt_t *jwt = NULL;
apr_jwt_error_t err;
TST_ASSERT_ERR("apr_jwt_parse", apr_jwt_parse(pool, s, &jwt, NULL, &err),
pool, err);
char *dst;
dst = NULL;
TST_ASSERT("apr_jwt_get_string (1a)",
apr_jwt_get_string(pool, jwt->header.value.json, "typ", TRUE, &dst, &err));
TST_ASSERT_STR("apr_jwt_get_string (1b)", dst, "JWT");
dst = NULL;
TST_ASSERT("apr_jwt_get_string (2a)",
apr_jwt_get_string(pool, jwt->header.value.json, "alg", TRUE, &dst, &err));
TST_ASSERT_STR("apr_jwt_get_string (2b)", dst, "HS256");
dst = NULL;
TST_ASSERT("apr_jwt_get_string (3a)",
apr_jwt_get_string(pool, jwt->header.value.json, "dummy", FALSE, &dst, &err));
TST_ASSERT_STR("apr_jwt_get_string (3b)", dst, NULL);
apr_jwt_destroy(jwt);
return 0;
}
示例2: LER_LerParmChar
int LER_LerParmChar( char * Parm )
{
tpElemSimbolo * pElem = NULL ;
#ifdef _DEBUG
TST_ASSERT( Inicializado ) ;
TST_ASSERT( Parm != NULL ) ;
#endif
PularBrancos( ) ;
/* Tratar parâmetro char simbólico */
if ( isalpha( LER_Buffer[ LER_InxBuffer ] ))
{
pElem = ObterDado( ID_TIPO_CHAR ) ;
if ( pElem == NULL )
{
*Parm = 0 ;
return FALSE ;
} /* if */
* Parm = pElem->ValorTipado.ValorChar ;
return TRUE ;
} /* fim ativa: Tratar parâmetro char simbólico */
/* Tratar parâmetro char literal */
if ( LER_Buffer[ LER_InxBuffer ] != '\'' )
{
* Parm = 0 ;
ExibirErro( "Faltou aspas antes de literal char." ) ;
return FALSE ;
} /* if */
LER_InxBuffer ++ ;
if ( LER_Buffer[ LER_InxBuffer ] == '\\' )
{
LER_InxBuffer ++ ;
*Parm = LerCharCntrl( ) ;
} else
{
*Parm = LER_Buffer[ LER_InxBuffer ] ;
LER_InxBuffer ++ ;
} /* if */
if ( LER_Buffer[ LER_InxBuffer ] != '\'' )
{
ExibirErro( "Faltou aspas após literal char." ) ;
return FALSE ;
} /* if */
LER_InxBuffer ++ ;
return TRUE ;
} /* Fim função: LER &Ler parâmetro caractere */
示例3: TBS_ExcluirSimbolo
TBS_tpCondRet TBS_ExcluirSimbolo( TBS_tppTabela pTabela ,
char * pSimbolo )
{
unsigned inxHash ;
tpLista * pElem ;
#ifdef _DEBUG
TST_ASSERT( pTabela != NULL ) ;
TST_ASSERT( pSimbolo != NULL ) ;
#endif
pElem = ProcurarSimbolo( pTabela , pSimbolo , &inxHash ) ;
if ( pElem == NULL )
{
return TBS_CondRetSimboloNaoExiste ;
} /* if */
if ( pElem->pProx != NULL )
{
pElem->pProx->pAnt = pElem->pAnt ;
} /* if */
if ( pElem->pAnt != NULL )
{
pElem->pAnt->pProx = pElem->pProx ;
} else {
pTabela->pVtHash[ inxHash ] = pElem->pProx ;
} /* if */
LiberarElemento( pTabela , pElem ) ;
return TBS_CondRetOK ;
} /* Fim função: TBS &Excluir símbolo */
示例4: test_jwt_parse
static char * test_jwt_parse(apr_pool_t *pool) {
// from http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-20
// 3.1. Example JWT
char *s = apr_pstrdup(pool,
"eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9" \
".eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ" \
".dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk");
apr_jwt_t *jwt = NULL;
TST_ASSERT("apr_jwt_parse", apr_jwt_parse(pool, s, &jwt, NULL, NULL));
TST_ASSERT_STR("header.alg", jwt->header.alg, "HS256");
TST_ASSERT_STR("header.enc", jwt->header.enc, NULL);
TST_ASSERT_STR("header.kid", jwt->header.kid, NULL);
TST_ASSERT_STR("payload.iss", jwt->payload.iss, "joe");
TST_ASSERT_LONG("payload.exp", (long)apr_time_sec(jwt->payload.exp), 1300819380L);
char *str_key = "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow";
char *raw_key = NULL;
int raw_key_len = apr_jwt_base64url_decode(pool, &raw_key, str_key, 1);
TST_ASSERT("apr_jws_verify_hmac", apr_jws_verify_hmac(pool, jwt, raw_key, raw_key_len));
s[5] = '.';
TST_ASSERT("corrupted header (1) apr_jwt_parse", apr_jwt_parse(pool, s, &jwt, NULL, NULL) == FALSE);
s[0] = '\0';
TST_ASSERT("corrupted header (2) apr_jwt_parse", apr_jwt_parse(pool, s, &jwt, NULL, NULL) == FALSE);
return 0;
}
示例5: LER_LerParmDouble
int LER_LerParmDouble( double * Parm )
{
tpElemSimbolo * pElem = NULL ;
int inxOrg ;
double ValDouble ;
#ifdef _DEBUG
TST_ASSERT( Inicializado ) ;
TST_ASSERT( Parm != NULL ) ;
#endif
PularBrancos( ) ;
/* Tratar parâmetro double simbólico */
if ( isalpha( LER_Buffer[ LER_InxBuffer ] ))
{
pElem = ObterDado( ID_TIPO_DOUBLE ) ;
if ( pElem == NULL )
{
*Parm = 0. ;
return FALSE ;
} /* if */
* Parm = pElem->ValorTipado.ValorDouble ;
return TRUE ;
} /* fim ativa: Tratar parâmetro double simbólico */
/* Tratar parâmetro double literal */
inxOrg = LER_InxBuffer ;
while ( LER_InxBuffer < LER_TamBuffer )
{
if ( EhBranco( LER_Buffer[ LER_InxBuffer ] ))
{
break ;
} /* if */
LER_InxBuffer ++ ;
} /* while */
if ( sscanf( LER_Buffer + inxOrg , "%lf" , &ValDouble ) != 1 )
{
ExibirErro( "Literal double errado." ) ;
*Parm = 0. ;
return FALSE ;
} /* if */
*Parm = ValDouble ;
return TRUE ;
} /* Fim função: LER &Ler parâmetro flutuante */
示例6: apr_array_make
static char *test_jwt_array_has_string(apr_pool_t *pool) {
apr_array_header_t *haystack = apr_array_make(pool, 3, sizeof(const char*));
*(const char**) apr_array_push(haystack) = "a";
*(const char**) apr_array_push(haystack) = "b";
*(const char**) apr_array_push(haystack) = "c";
TST_ASSERT("jwt_array_has_string (1)",
apr_jwt_array_has_string(haystack, "a"));
TST_ASSERT("jwt_array_has_string (2)",
apr_jwt_array_has_string(haystack, "d") == FALSE);
return 0;
}
示例7: LER_ExibirParametro
void LER_ExibirParametro( char * Simbolo )
{
tpElemSimbolo * pElem ;
#ifdef _DEBUG
TST_ASSERT( Inicializado ) ;
#endif
pElem = ( tpElemSimbolo * ) TBS_ProcurarSimbolo( pTabela , Simbolo ) ;
if ( pElem == NULL )
{
TST_ExibirPrefixo( INFO_LER , "Parâmetro não definido: " ) ;
fprintf( TST_ObterArqLog( ) , "%s" , Simbolo ) ;
return ;
} /* if */
TST_ExibirPrefixo( INFO_LER , "Parâmetro: " ) ;
fprintf( TST_ObterArqLog( ) , "%s" , Simbolo ) ;
TST_ExibirEspacoHexa( sizeof( tpElemSimbolo ) , pElem ) ;
if ( ( pElem->idTipo == ID_TIPO_STRING )
|| ( pElem->idTipo == ID_TIPO_NOME ))
{
TST_ExibirEspacoHexa( strlen( pElem->ValorTipado.ValorString ) + 1 ,
pElem->ValorTipado.ValorString ) ;
} /* if */
} /* Fim função: LER &Exibir declaração de símbolo */
示例8: TST_ASSERT
static char *test_jwt_url_encode_decode(apr_pool_t *pool) {
char *dst = NULL;
char *src = "abcd";
TST_ASSERT("apr_jwt_base64url_encode (1)",
apr_jwt_base64url_encode(pool, &dst, src, strlen(src), 0));
TST_ASSERT_STR("apr_jwt_base64url_encode (2)", dst, "YWJjZA");
src = dst;
TST_ASSERT("apr_jwt_base64url_decode (1)",
apr_jwt_base64url_decode(pool, &dst, src, 1));
TST_ASSERT_STR("apr_jwt_base64url_decode (2)", dst, "abcd");
return 0;
}
示例9: LER_AbrirArquivoScript
LER_tpCondRet LER_AbrirArquivoScript( char * NomeArqParm )
{
#ifdef _DEBUG
TST_ASSERT( Inicializado ) ;
#endif
strcpy( NomeArqScript , NomeArqParm ) ;
if ( TST_ObterInicioExtensao( NomeArqScript ) == NULL )
{
strcat( NomeArqScript , DEFAULT_EXT_SCRIPT ) ;
} /* if */
pArqScript = fopen( NomeArqScript , "rb" ) ;
if ( pArqScript != NULL )
{
printf( "\n Arquivo de teste: %s\n" , NomeArqParm ) ;
AcabouScript = 0 ;
return LER_CondRetOK ;
} /* if */
NomeArqScript[ 0 ] = 0 ;
return LER_CondRetNaoAbriu ;
} /* Fim função: LER &Abrir arquivo script de teste */
示例10: test_proto_authorization_request
static char * test_proto_authorization_request(request_rec *r) {
oidc_provider_t provider;
provider.issuer = "https://idp.example.com";
provider.authorization_endpoint_url = "https://idp.example.com/authorize";
provider.scope = "openid";
provider.client_id = "client_id";
provider.response_type = "code";
provider.auth_request_params = NULL;
const char *redirect_uri = "https://www.example.com/protected/";
const char *state = "12345";
json_t * proto_state = json_object();
json_object_set_new(proto_state, "nonce", json_string("anonce"));
json_object_set_new(proto_state, "original_url", json_string("https://localhost/protected/index.php"));
json_object_set_new(proto_state, "original_method", json_string("get"));
json_object_set_new(proto_state, "issuer", json_string(provider.issuer));
json_object_set_new(proto_state, "response_type", json_string(provider.response_type));
json_object_set_new(proto_state, "timestamp", json_integer(apr_time_sec(apr_time_now())));
TST_ASSERT("oidc_proto_authorization_request (1)",
oidc_proto_authorization_request(r, &provider, NULL, redirect_uri, state, proto_state, NULL, NULL) == HTTP_MOVED_TEMPORARILY);
TST_ASSERT_STR("oidc_proto_authorization_request (2)",
apr_table_get(r->headers_out, "Location"),
"https://idp.example.com/authorize?response_type=code&scope=openid&client_id=client_id&state=12345&redirect_uri=https%3A%2F%2Fwww.example.com%2Fprotected%2F&nonce=anonce");
return 0;
}
示例11: LER_PularComando
void LER_PularComando( void )
{
int TemComando = 0 ;
#ifdef _DEBUG
TST_ASSERT( Inicializado ) ;
#endif
while ( LER_InxBuffer < LER_TamBuffer )
{
if ( LER_Buffer[ LER_InxBuffer ] == PREFIXO_COMANDO )
{
TemComando = 1 ;
} else if ( EhBranco( LER_Buffer[ LER_InxBuffer ] ))
{
if ( TemComando )
{
break ;
} /* if */
} /* if */
LER_InxBuffer ++ ;
} /* while */
} /* Fim função: LER &Pular comando de teste */
示例12: TBS_DestruirTabela
void TBS_DestruirTabela( TBS_tppTabela pTabela )
{
unsigned inxElem ;
tpLista * pElem ;
tpLista * pProx ;
#ifdef _DEBUG
TST_ASSERT( pTabela != NULL ) ;
#endif
for ( inxElem = 0 ; inxElem < pTabela->tamVtHash ; inxElem++ ) {
/* Destruir todos elementos de lista de colisão */
pElem = pTabela->pVtHash[ inxElem ] ;
while ( pElem != NULL )
{
pProx = pElem->pProx ;
LiberarElemento( pTabela , pElem ) ;
pElem = pProx ;
} /* while */
} /* fim repete: Raiz de TBS &Destruir tabela de símbolos */
free( pTabela->pVtHash ) ;
free( pTabela ) ;
} /* Fim função: TBS &Destruir tabela de símbolos */
示例13: LER_InicializarLeitura
int LER_InicializarLeitura( void )
{
#ifdef _DEBUG
TST_ASSERT( ! Inicializado ) ;
#endif
NomeArqScript[ 0 ] = 0 ;
pArqScript = NULL ;
AcabouScript = 1 ;
ContaLinhas = 0 ;
LER_Buffer[ 0 ] = 0 ;
LER_TamBuffer = 0 ;
pTabela = TBS_CriarTabela( DIM_TABELA , ObterSimbolo , NULL ) ;
if ( pTabela == NULL )
{
return FALSE ;
} /* if */
Inicializado = 1 ;
return TRUE ;
} /* Fim função: LER &Inicializar módulo LerParm */
示例14: test_proto_validate_nonce
static char * test_proto_validate_nonce(request_rec *r) {
oidc_cfg *c = ap_get_module_config(r->server->module_config,
&auth_openidc_module);
const char *nonce = "avSk7S69G4kEE8Km4bPiOjrfChHt6nO4Z397Lp_bQnc,";
/*
* {
* "typ": "JWT",
* "alg": "RS256",
* "x5t": "Z1NCjojeiHAib-Gm8vFE6ya6lPM"
* }
* {
* "nonce": "avSk7S69G4kEE8Km4bPiOjrfChHt6nO4Z397Lp_bQnc,",
* "iat": 1411580876,
* "at_hash": "yTqsoONZbuWbN6TbgevuDQ",
* "sub": "6343a29c-5399-44a7-9b35-4990f4377c96",
* "amr": "password",
* "auth_time": 1411577267,
* "idp": "idsrv",
* "name": "ksonaty",
* "iss": "https://agsync.com",
* "aud": "agsync_implicit",
* "exp": 1411584475,
* "nbf": 1411580875
* }
*/
char *s_jwt =
apr_pstrdup(r->pool,
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IloxTkNqb2plaUhBaWItR204dkZFNnlhNmxQTSJ9.eyJub25jZSI6ImF2U2s3UzY5RzRrRUU4S200YlBpT2pyZkNoSHQ2bk80WjM5N0xwX2JRbmMsIiwiaWF0IjoxNDExNTgwODc2LCJhdF9oYXNoIjoieVRxc29PTlpidVdiTjZUYmdldnVEUSIsInN1YiI6IjYzNDNhMjljLTUzOTktNDRhNy05YjM1LTQ5OTBmNDM3N2M5NiIsImFtciI6InBhc3N3b3JkIiwiYXV0aF90aW1lIjoxNDExNTc3MjY3LCJpZHAiOiJpZHNydiIsIm5hbWUiOiJrc29uYXR5IiwiaXNzIjoiaHR0cHM6Ly9hZ3N5bmMuY29tIiwiYXVkIjoiYWdzeW5jX2ltcGxpY2l0IiwiZXhwIjoxNDExNTg0NDc1LCJuYmYiOjE0MTE1ODA4NzV9.lEG-DgHHa0JuOEuOTBvCqyexjRVcKXBnJJm289o2HyTgclpH80DsOMED9RlXCFfuDY7nw9i2cxUmIMAV42AdTxkMPomK3chytcajvpAZJirlk653bo9GTDXJSKZr5fwyEu--qahsoT5t9qvoWyFdYkvmMHFw1-mAHDGgVe23voc9jPuFFIhRRqIn4e8ikzN4VQeEV1UXJD02kYYFn2TRWURgiFyVeTr2r0MTn-auCEsFS_AfR1Bl_kmpMfqwrsicf5MTBvfPJeuSMt3t3d3LOGBkg36_z21X-ZRN7wy1KTjagr7iQ_y5csIpmtqs_QM55TTB9dW1HIosJPhiuMEJEA");
apr_jwt_t *jwt = NULL;
apr_jwt_error_t err;
TST_ASSERT_ERR("apr_jwt_parse",
apr_jwt_parse(r->pool, s_jwt, &jwt, NULL, &err), r->pool, err);
TST_ASSERT("oidc_proto_validate_nonce (1)",
oidc_proto_validate_nonce(r, c, &c->provider, nonce, jwt));
TST_ASSERT("oidc_proto_validate_nonce (2)",
oidc_proto_validate_nonce( r, c, &c->provider, nonce, jwt) == FALSE);
apr_jwt_destroy(jwt);
return 0;
}
示例15: LER_LerParmNome
int LER_LerParmNome( char * Parm , int * tamNome , int dimNome )
{
int inxParm = 0 ;
#ifdef _DEBUG
TST_ASSERT( Inicializado ) ;
#endif
PularBrancos( ) ;
*tamNome = 0 ;
if ( ! isalpha( LER_Buffer[ LER_InxBuffer ] ))
{
ExibirErro( "Nome deve iniciar com letra." ) ;
Parm[ inxParm ] = 0 ;
return 0 ;
} /* if */
Parm[ inxParm ] = LER_Buffer[ LER_InxBuffer ] ;
LER_InxBuffer ++ ;
inxParm ++ ;
while ( LER_InxBuffer < LER_TamBuffer )
{
if ( __iscsym( LER_Buffer[ LER_InxBuffer ] ))
{
Parm[ inxParm ] = LER_Buffer[ LER_InxBuffer ] ;
} else
{
Parm[ inxParm ] = 0 ;
*tamNome = inxParm ;
return TRUE ;
} /* if */
LER_InxBuffer ++ ;
inxParm ++ ;
if ( inxParm > dimNome )
{
ExibirErro( "Nome longo demais." ) ;
Parm[ dimNome - 1 ] = 0 ;
*tamNome = dimNome - 1 ;
return FALSE ;
} /* if */
} /* while */
Parm[ inxParm ] = 0 ;
*tamNome = inxParm ;
return TRUE ;
} /* Fim função: LER &Ler parâmetro nome */