fixed
This commit is contained in:
+6
-6
@@ -44,16 +44,16 @@ type User struct {
|
|||||||
LastName string `json:"last_name" db:"last_name"`
|
LastName string `json:"last_name" db:"last_name"`
|
||||||
Suffix string `json:"suffix" db:"suffix"`
|
Suffix string `json:"suffix" db:"suffix"`
|
||||||
EmailAddress string `json:"email_address" db:"email_address"`
|
EmailAddress string `json:"email_address" db:"email_address"`
|
||||||
EmpID string `json:"emp_id" db:"emp_id"`
|
|
||||||
IsLoggedIn string `json:"is_logged_in" db:"is_logged_in"`
|
|
||||||
FirstLoggedIn string `json:"first_logged_in" db:"first_logged_in"`
|
|
||||||
HomeAddress string `json:"home_address" db:"home_address"`
|
HomeAddress string `json:"home_address" db:"home_address"`
|
||||||
ContactNumber string `json:"contact_number" db:"contact_number"`
|
ContactNumber string `json:"contact_number" db:"contact_number"`
|
||||||
DeviceID string `json:"device_id" db:"device_id"`
|
|
||||||
RoleID int `json:"role_id" db:"role_id"`
|
RoleID int `json:"role_id" db:"role_id"`
|
||||||
IsDeleted string `json:"is_deleted" db:"is_deleted"`
|
IsDeleted string `json:"is_deleted" db:"is_deleted"`
|
||||||
SecretKey string `json:"secret_key" db:"secret_key"`
|
|
||||||
IsActivated string `json:"is_activated" db:"is_activated"`
|
|
||||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ func GetUserAttributes(userID string) (map[string]string, error) {
|
|||||||
func GetUserByID(userID string) (*models.User, error) {
|
func GetUserByID(userID string) (*models.User, error) {
|
||||||
query := `
|
query := `
|
||||||
SELECT user_id, first_name, middle_initial, last_name, suffix, email_address,
|
SELECT user_id, first_name, middle_initial, last_name, suffix, email_address,
|
||||||
emp_id, is_logged_in, first_logged_in, home_address, contact_number, device_id,
|
home_address, contact_number,
|
||||||
role_id, is_deleted, secret_key, is_activated, created_at, updated_at
|
role_id, is_deleted, created_at, updated_at
|
||||||
FROM uess_user_management.users
|
FROM uess_user_management.users
|
||||||
WHERE user_id = ? AND is_deleted = 'N'
|
WHERE user_id = ? AND is_deleted = 'N'
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
@@ -115,16 +115,16 @@ func GetUserByID(userID string) (*models.User, error) {
|
|||||||
&user.LastName,
|
&user.LastName,
|
||||||
&user.Suffix,
|
&user.Suffix,
|
||||||
&user.EmailAddress,
|
&user.EmailAddress,
|
||||||
&user.EmpID,
|
|
||||||
&user.IsLoggedIn,
|
|
||||||
&user.FirstLoggedIn,
|
|
||||||
&user.HomeAddress,
|
&user.HomeAddress,
|
||||||
&user.ContactNumber,
|
&user.ContactNumber,
|
||||||
&user.DeviceID,
|
|
||||||
&user.RoleID,
|
&user.RoleID,
|
||||||
&user.IsDeleted,
|
&user.IsDeleted,
|
||||||
&user.SecretKey,
|
|
||||||
&user.IsActivated,
|
|
||||||
&user.CreatedAt,
|
&user.CreatedAt,
|
||||||
&user.UpdatedAt,
|
&user.UpdatedAt,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ func TestGetUserByIDSuccess(t *testing.T) {
|
|||||||
|
|
||||||
rows := sqlmock.NewRows([]string{
|
rows := sqlmock.NewRows([]string{
|
||||||
"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
||||||
"emp_id", "is_logged_in", "first_logged_in", "home_address", "contact_number", "device_id",
|
"home_address", "contact_number",
|
||||||
"role_id", "is_deleted", "secret_key", "is_activated", "created_at", "updated_at",
|
"role_id", "is_deleted", "created_at", "updated_at",
|
||||||
}).AddRow(
|
}).AddRow(
|
||||||
"user123", "John", "M", "Doe", "Jr", "john@example.com",
|
"user123", "John", "M", "Doe", "Jr", "john@example.com",
|
||||||
"EMP001", "Y", "Y", "123 Main St", "1234567890", "device001",
|
"EMP001", "Y", "Y", "123 Main St", "1234567890", "device001",
|
||||||
@@ -315,8 +315,8 @@ func TestGetUserByIDEmptyID(t *testing.T) {
|
|||||||
|
|
||||||
rows := sqlmock.NewRows([]string{
|
rows := sqlmock.NewRows([]string{
|
||||||
"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
||||||
"emp_id", "is_logged_in", "first_logged_in", "home_address", "contact_number", "device_id",
|
"home_address", "contact_number",
|
||||||
"role_id", "is_deleted", "secret_key", "is_activated", "created_at", "updated_at",
|
"role_id", "is_deleted", "created_at", "updated_at",
|
||||||
})
|
})
|
||||||
|
|
||||||
// Match the actual query format with all the fields
|
// Match the actual query format with all the fields
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ func TestAuthorize_PermissionNotFound(t *testing.T) {
|
|||||||
|
|
||||||
// Mock user query
|
// Mock user query
|
||||||
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
||||||
"emp_id", "is_logged_in", "first_logged_in", "home_address", "contact_number", "device_id",
|
"home_address", "contact_number",
|
||||||
"role_id", "is_deleted", "secret_key", "is_activated", "created_at", "updated_at"}).
|
"role_id", "is_deleted", "created_at", "updated_at"}).
|
||||||
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
||||||
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
||||||
1, "N", "secret", "Y", time.Now(), time.Now())
|
1, "N", "secret", "Y", time.Now(), time.Now())
|
||||||
@@ -83,8 +83,8 @@ func TestAuthorize_Success(t *testing.T) {
|
|||||||
|
|
||||||
// Mock user query
|
// Mock user query
|
||||||
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
||||||
"emp_id", "is_logged_in", "first_logged_in", "home_address", "contact_number", "device_id",
|
"home_address", "contact_number",
|
||||||
"role_id", "is_deleted", "secret_key", "is_activated", "created_at", "updated_at"}).
|
"role_id", "is_deleted", "created_at", "updated_at"}).
|
||||||
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
||||||
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
||||||
1, "N", "secret", "Y", time.Now(), time.Now())
|
1, "N", "secret", "Y", time.Now(), time.Now())
|
||||||
@@ -143,8 +143,8 @@ func TestAuthorize_UserAttributesError(t *testing.T) {
|
|||||||
|
|
||||||
// Mock user query
|
// Mock user query
|
||||||
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
||||||
"emp_id", "is_logged_in", "first_logged_in", "home_address", "contact_number", "device_id",
|
"home_address", "contact_number",
|
||||||
"role_id", "is_deleted", "secret_key", "is_activated", "created_at", "updated_at"}).
|
"role_id", "is_deleted", "created_at", "updated_at"}).
|
||||||
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
||||||
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
||||||
1, "N", "secret", "Y", time.Now(), time.Now())
|
1, "N", "secret", "Y", time.Now(), time.Now())
|
||||||
@@ -190,8 +190,8 @@ func TestAuthorize_PolicyAttributesError(t *testing.T) {
|
|||||||
|
|
||||||
// Mock user query
|
// Mock user query
|
||||||
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
||||||
"emp_id", "is_logged_in", "first_logged_in", "home_address", "contact_number", "device_id",
|
"home_address", "contact_number",
|
||||||
"role_id", "is_deleted", "secret_key", "is_activated", "created_at", "updated_at"}).
|
"role_id", "is_deleted", "created_at", "updated_at"}).
|
||||||
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
||||||
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
||||||
1, "N", "secret", "Y", time.Now(), time.Now())
|
1, "N", "secret", "Y", time.Now(), time.Now())
|
||||||
|
|||||||
@@ -220,8 +220,8 @@ func TestAuthorizeWithCache_Success(t *testing.T) {
|
|||||||
|
|
||||||
// Mock user query (needed to get role_id)
|
// Mock user query (needed to get role_id)
|
||||||
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
||||||
"emp_id", "is_logged_in", "first_logged_in", "home_address", "contact_number", "device_id",
|
"home_address", "contact_number",
|
||||||
"role_id", "is_deleted", "secret_key", "is_activated", "created_at", "updated_at"}).
|
"role_id", "is_deleted", "created_at", "updated_at"}).
|
||||||
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
||||||
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
||||||
1, "N", "secret", "Y", time.Now(), time.Now())
|
1, "N", "secret", "Y", time.Now(), time.Now())
|
||||||
@@ -275,8 +275,8 @@ func TestAuthorizeWithCache_PermissionNotFound(t *testing.T) {
|
|||||||
|
|
||||||
// Mock user query
|
// Mock user query
|
||||||
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
userRows := sqlmock.NewRows([]string{"user_id", "first_name", "middle_initial", "last_name", "suffix", "email_address",
|
||||||
"emp_id", "is_logged_in", "first_logged_in", "home_address", "contact_number", "device_id",
|
"home_address", "contact_number",
|
||||||
"role_id", "is_deleted", "secret_key", "is_activated", "created_at", "updated_at"}).
|
"role_id", "is_deleted", "created_at", "updated_at"}).
|
||||||
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
AddRow("user123", "John", "", "Doe", "", "john@example.com",
|
||||||
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
"EMP123", "Y", "Y", "123 Street", "09123456789", "device1",
|
||||||
1, "N", "secret", "Y", time.Now(), time.Now())
|
1, "N", "secret", "Y", time.Now(), time.Now())
|
||||||
|
|||||||
Reference in New Issue
Block a user