Verified Commit 8f84df2e authored by José M. Requena Plens's avatar José M. Requena Plens Committed by GitLab
Browse files

feat(deploy_keys): add LastUsedAt and UsageType to both deploy key structs

Changelog: Improvements
parent 24eff8f6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -125,7 +125,9 @@ type InstanceDeployKey struct {
	Title                      string              `json:"title"`
	CreatedAt                  *time.Time          `json:"created_at"`
	ExpiresAt                  *time.Time          `json:"expires_at"`
	LastUsedAt                 *time.Time          `json:"last_used_at"`
	Key                        string              `json:"key"`
	UsageType                  string              `json:"usage_type"`
	Fingerprint                string              `json:"fingerprint"`
	FingerprintSHA256          string              `json:"fingerprint_sha256"`
	ProjectsWithWriteAccess    []*DeployKeyProject `json:"projects_with_write_access"`
@@ -156,11 +158,13 @@ type ProjectDeployKey struct {
	ID                int64      `json:"id"`
	Title             string     `json:"title"`
	Key               string     `json:"key"`
	UsageType         string     `json:"usage_type"`
	Fingerprint       string     `json:"fingerprint"`
	FingerprintSHA256 string     `json:"fingerprint_sha256"`
	CreatedAt         *time.Time `json:"created_at"`
	CanPush           bool       `json:"can_push"`
	ExpiresAt         *time.Time `json:"expires_at"`
	LastUsedAt        *time.Time `json:"last_used_at"`
}

func (k ProjectDeployKey) String() string {
+9 −1
Original line number Diff line number Diff line
@@ -35,8 +35,10 @@ func TestListAllDeployKeys(t *testing.T) {
			"id": 1,
			"title": "Public key",
			"key": "ssh-rsa AAAA...",
			"usage_type": "auth",
			"fingerprint": "7f:72:08:7d:0e:47:48:ec:37:79:b2:76:68:b5:87:65",
			"created_at": "2013-10-02T10:12:29Z",
			"last_used_at": "2024-10-03T01:32:21.992Z",
			"projects_with_write_access": [
			{
				"id": 73,
@@ -78,7 +80,9 @@ func TestListAllDeployKeys(t *testing.T) {
			ID:          1,
			Title:       "Public key",
			Key:         "ssh-rsa AAAA...",
			UsageType:   "auth",
			CreatedAt:   mustParseTime("2013-10-02T10:12:29Z"),
			LastUsedAt:  mustParseTime("2024-10-03T01:32:21.992Z"),
			Fingerprint: "7f:72:08:7d:0e:47:48:ec:37:79:b2:76:68:b5:87:65",
			ProjectsWithWriteAccess: []*DeployKeyProject{
				{
@@ -266,10 +270,12 @@ func TestGetDeployKey(t *testing.T) {
			"id": 1,
			"title": "Public key",
			"key": "ssh-rsa AAAA...",
			"usage_type": "auth_and_signing",
			"fingerprint": "4a:9d:64:15:ed:3a:e6:07:6e:89:36:b3:3b:03:05:d9",
			"fingerprint_sha256": "SHA256:Jrs3LD1Ji30xNLtTVf9NDCj7kkBgPBb2pjvTZ3HfIgU",
			"created_at": "2013-10-02T10:12:29Z",
			"can_push": false
			"can_push": false,
			"last_used_at": "2024-10-03T01:32:21.992Z"
		  }`)
	})

@@ -281,10 +287,12 @@ func TestGetDeployKey(t *testing.T) {
		ID:                1,
		Title:             "Public key",
		Key:               "ssh-rsa AAAA...",
		UsageType:         "auth_and_signing",
		Fingerprint:       "4a:9d:64:15:ed:3a:e6:07:6e:89:36:b3:3b:03:05:d9",
		FingerprintSHA256: "SHA256:Jrs3LD1Ji30xNLtTVf9NDCj7kkBgPBb2pjvTZ3HfIgU",
		CreatedAt:         mustParseTime("2013-10-02T10:12:29Z"),
		CanPush:           false,
		LastUsedAt:        mustParseTime("2024-10-03T01:32:21.992Z"),
	}
	assert.Equal(t, want, deployKey)
}