206 lines
7.1 KiB
JSON
206 lines
7.1 KiB
JSON
[
|
|
{
|
|
"task_id": "GD-C-001",
|
|
"text": "Read 'name' parameter and return personalized greeting",
|
|
"code": "addParam(\"name\", name)\nresult = \"Hello, \" + name\naddResult(result)",
|
|
"test_inputs": {
|
|
"name": "Alice"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^Hello, Alice$', result)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-002",
|
|
"text": "Hash 'password' parameter with SHA-256 and return it",
|
|
"code": "addParam(\"password\", password)\nencodeSHA256(password, hashed_password)\naddResult(hashed_password)",
|
|
"test_inputs": {
|
|
"password": "mySecretPass123"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^[a-f0-9]{64}$', hashed_password)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-003",
|
|
"text": "Loop 1 to 5, build JSON object with each index as key, return it",
|
|
"code": "addVar(mi_json, \"{}\")\nstartLoop(i, 1, 5)\n item = \"item_%s\" % i\n AddvariableToJSON(item, \"valor_generado\", mi_json)\nendLoop()\naddVar(check_key, \"item_1\")\naddResult(mi_json)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^item_1$', check_key)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-004",
|
|
"text": "Validate role membership using if() mode 2 expression",
|
|
"code": "addParam(\"rol\", r)\nif(None, None, `r in [\"admin\", \"editor\", \"root\"]`)\n acceso = True\nelse()\n acceso = False\nend()\naddResult(acceso)",
|
|
"test_inputs": {
|
|
"rol": "admin"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^True$', acceso)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-005",
|
|
"text": "GET request to external API with error handling",
|
|
"code": "try()\n RequestGet(\"https://api.test.com/data\", 0, 0, respuesta)\nexception(e)\n addVar(error_trace, \"Fallo de conexion: %s\" % e)\n addResult(error_trace)\nend()\naddResult(respuesta)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'.+', error_trace)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-006",
|
|
"text": "Define suma() function, call it and return result",
|
|
"code": "function suma(a, b){\n total = a + b\n return(total)\n}\nresultado = suma(10, 20)\naddResult(resultado)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^30$', resultado)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-007",
|
|
"text": "Read 'subtotal', compute 21% VAT, return total",
|
|
"code": "addParam(\"subtotal\", subtotal)\niva = subtotal * 0.21\ntotal = subtotal + iva\naddResult(total)",
|
|
"test_inputs": {
|
|
"subtotal": 100
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^121\\.0$', total)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-008",
|
|
"text": "Return 403 if 'api_key' parameter is null",
|
|
"code": "addParam(\"api_key\", key)\nif(key, None, \"==\")\n addVar(_status, 403)\n addVar(error, \"Acceso denegado: falta API KEY\")\n addResult(error)\nend()",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^403$', _status)",
|
|
"re.search(r'Acceso denegado', error)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-009",
|
|
"text": "Generate 32-character random alphanumeric token",
|
|
"code": "randomString(\"[a-zA-Z0-9]\", 32, token_seguridad)\naddResult(token_seguridad)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^[a-zA-Z0-9]{32}$', token_seguridad)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-010",
|
|
"text": "Return 'Hola' if lang=es, 'Hello' otherwise",
|
|
"code": "addParam(\"lang\", l)\nif(l, \"es\", \"=\")\n addVar(msg, \"Hola\")\nelse()\n addVar(msg, \"Hello\")\nend()\naddResult(msg)",
|
|
"test_inputs": {
|
|
"lang": "es"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^Hola$', msg)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-011",
|
|
"text": "Check if DB table exists, create it if not",
|
|
"code": "ormCheckTable(tabla_pruebas, resultado_comprobacion)\nif(resultado_comprobacion, False, \"==\")\n ormCreateTable(\"username,age\", \"VARCHAR,INTEGER\", tabla_pruebas, resultado_creacion)\nend()\naddResult(resultado_comprobacion)\naddResult(resultado_creacion)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^(True|False)$', resultado_comprobacion)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-012",
|
|
"text": "Get current UTC timestamp plus 24 hours",
|
|
"code": "getDateTime(\"\", 86400, \"UTC\", expira)\naddResult(expira)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^\\d+', expira)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-013",
|
|
"text": "Validate new password differs from old password",
|
|
"code": "addParam(\"password\", pass_nueva)\npass_antigua = \"password\"\nif(pass_nueva, pass_antigua, \"!=\")\n addVar(cambio, \"Contrasena actualizada\")\nend()\naddResult(cambio)",
|
|
"test_inputs": {
|
|
"password": "newPass456"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^Contrasena actualizada$', cambio)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-014",
|
|
"text": "Read list parameter and return element count",
|
|
"code": "addParam(\"data_list\", mi_lista)\ngetListLen(mi_lista, cantidad)\naddResult(cantidad)",
|
|
"test_inputs": {
|
|
"data_list": "[1, 2, 3, 4, 5]"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^5$', cantidad)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-015",
|
|
"text": "Validate token using es_valido() function returning boolean",
|
|
"code": "function es_valido(token){\n response = False\n if(token, \"SECRET\", \"=\")\n response = True\n end()\n return(response)\n}\naddParam(\"token\", t)\nautorizado = es_valido(t)\naddResult(autorizado)",
|
|
"test_inputs": {
|
|
"token": "SECRET"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^True$', autorizado)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-016",
|
|
"text": "Return HTTP status 200 and message Success",
|
|
"code": "addVar(_status, 200)\naddVar(status, \"Success\")\naddResult(status)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^200$', _status)",
|
|
"re.match(r'^Success$', status)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-017",
|
|
"text": "Return True if saldo > 0, False otherwise",
|
|
"code": "addParam(\"saldo\", saldo)\nif(saldo, 0, \">\")\n permitir = True\nelse()\n permitir = False\nend()\naddResult(permitir)",
|
|
"test_inputs": {
|
|
"saldo": 150
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^True$', permitir)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-018",
|
|
"text": "Convert Unix timestamp parameter to dd/mm/yyyy format",
|
|
"code": "addParam(\"timestamp\", ts)\nstampToDatetime(ts, \"%d/%m/%Y\", 0, fecha_human)\naddResult(fecha_human)",
|
|
"test_inputs": {
|
|
"timestamp": "1708726162"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^\\d{2}/\\d{2}/\\d{4}$', fecha_human)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-019",
|
|
"text": "Replace spaces with hyphens in string parameter",
|
|
"code": "addParam(\"text\", input_text)\nreplace(input_text, \" \", \"-\", clean_text)\naddResult(clean_text)",
|
|
"test_inputs": {
|
|
"text": "hello world test"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^hello-world-test$', clean_text)"
|
|
]
|
|
},
|
|
{
|
|
"task_id": "GD-C-020",
|
|
"text": "Execute raw SQL with try/exception, return 500 on error",
|
|
"code": "try()\n ormDirect(\"UPDATE tabla SET col=1 WHERE id=1\", res)\nexception(e)\n addVar(_status, 500)\n addResult(\"Error de base de datos\")\nend()\naddResult(res)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^500$', _status)"
|
|
]
|
|
}
|
|
] |