< Summary - Backend C Tests - Coverage Report

Information
Class: auth_handler_c
Assembly: src.backend.api.handlers
File(s): C:\Users\yagiz\Desktop\Project\smart-maintenance-suite\src\backend\api\handlers\auth_handler.c
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 29
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
handle_auth_request100%00100%

File(s)

C:\Users\yagiz\Desktop\Project\smart-maintenance-suite\src\backend\api\handlers\auth_handler.c

#LineLine coverage
 1#include "auth_handler.h"
 2#include "../../database/cJSON.h"
 3#include "../../security/jwt.h"
 4#include <string.h>
 5#include <stdlib.h>
 6#include <stdio.h>
 7
 18void handle_auth_request(HttpRequest *req, HttpResponse *res) {
 9  // Mock kullanıcı bilgileri
 110  int user_id = 1;
 111  const char *username = "admin";
 112  const char *role = "admin";
 13  // jwt.h'daki orijinal generate_auth_token fonksiyonunu çağır
 114  char *token = generate_auth_token(user_id, username, role);
 115  cJSON *root = cJSON_CreateObject();
 116  cJSON_AddBoolToObject(root, "success", true);
 117  cJSON_AddStringToObject(root, "status", "authenticated");
 118  cJSON_AddStringToObject(root, "token", token);
 119  cJSON_AddStringToObject(root, "role", role);
 120  cJSON_AddStringToObject(root, "username", username);
 121  char *json = cJSON_Print(root);
 122  cJSON_Delete(root);
 123  free(token);
 124  res->status_code = 200;
 125  strcpy(res->content_type, "application/json");
 126  strncpy(res->body, json, 8191);
 127  res->body[8191] = '\0';
 128  free(json);
 129}

Methods/Properties

handle_auth_request