Skip to content

Commit

Permalink
[transfer] Fix date_imported to use a correct UNIX timestamp (#8095)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgorny authored Sep 8, 2024
1 parent 00bf688 commit a15f866
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions moto/transfer/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""TransferBackend class with methods for supported APIs."""

from datetime import datetime
from typing import Any, Dict, List, Optional, Tuple

from moto.core.base_backend import BackendDict, BaseBackend
from moto.core.utils import unix_time
from moto.transfer.exceptions import PublicKeyNotFound, ServerNotFound, UserNotFound

from .types import (
Expand Down Expand Up @@ -167,10 +167,10 @@ def create_user(
}
user.posix_profile = posix_profile
if ssh_public_key_body is not None:
now = datetime.now().strftime("%Y%m%d%H%M%S")
now = unix_time()
ssh_public_keys = [
{
"date_imported": now,
"date_imported": str(now),
"ssh_public_key_body": ssh_public_key_body,
"ssh_public_key_id": "mock_ssh_public_key_id_{ssh_public_key_body}_{now}",
}
Expand Down Expand Up @@ -205,14 +205,14 @@ def import_ssh_public_key(
raise ServerNotFound(server_id=server_id)
for user in self.servers[server_id]._users:
if user.user_name == user_name:
date_imported = datetime.now().strftime("%Y%m%d%H%M%S")
date_imported = unix_time()
ssh_public_key_id = (
f"{server_id}:{user_name}:public_key:{date_imported}"
)
key = {
"ssh_public_key_id": ssh_public_key_id,
"ssh_public_key_body": ssh_public_key_body,
"date_imported": date_imported,
"date_imported": str(date_imported),
}
user.ssh_public_keys.append(key)
return server_id, ssh_public_key_id, user_name
Expand Down

0 comments on commit a15f866

Please sign in to comment.