Skip to content

Commit

Permalink
expanded the TLSCertificate and Service asset types
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Sep 18, 2024
1 parent 7a1ed3b commit 3542fcb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion certificate/tls_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestTLSCertificateJSON(t *testing.T) {
}

// test JSON method
expectedJSON := `{"version":"","serial_number":"","subject_common_name":"www.example.org","issuer_common_name":"DigiCert TLS RSA SHA256 2020 CA1","not_before":"2006-01-02T15:04:05Z07:00","not_after":"2006-01-02T15:04:05Z07:00","key_usage":null,"signature_algorithm":"","public_key_algorithm":"","is_ca":false,"crl_distribution_points":null,"subject_key_id":"","authority_key_id":""}`
expectedJSON := `{"version":"","serial_number":"","subject_common_name":"www.example.org","issuer_common_name":"DigiCert TLS RSA SHA256 2020 CA1","not_before":"2006-01-02T15:04:05Z07:00","not_after":"2006-01-02T15:04:05Z07:00","key_usage":null,"ext_key_usage":null,"signature_algorithm":"","public_key_algorithm":"","is_ca":false,"crl_distribution_points":null,"subject_key_id":"","authority_key_id":""}`
json, err := cert.JSON()
if err != nil {
t.Errorf("Unexpected error: %v", err)
Expand Down
6 changes: 4 additions & 2 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
)

type Service struct {
Identifier string `json:"identifier"`
Version string `json:"version"`
Identifier string `json:"identifier"`
Banner string `json:"banner"`
BannerLen int `json:"banner_length"`
Headers map[string][]string `json:"headers"`
}

// Key implements the Asset interface.
Expand Down
6 changes: 4 additions & 2 deletions service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ func TestServiceAssetType(t *testing.T) {
func TestServiceJSON(t *testing.T) {
s := Service{
Identifier: "12345",
Version: "v1.0.1",
Banner: "Hello",
BannerLen: 5,
Headers: map[string][]string{"server": []string{"nginx-1.26.0"}},
}

// test AssetType method
Expand All @@ -43,7 +45,7 @@ func TestServiceJSON(t *testing.T) {
}

// Test JSON method
expectedJSON := `{"identifier":"12345","version":"v1.0.1"}`
expectedJSON := `{"identifier":"12345","banner":"Hello","banner_length":5,"headers":{"server":["nginx-1.26.0"]}}`
json, err := s.JSON()
if err != nil {
t.Errorf("Unexpected error: %v", err)
Expand Down

0 comments on commit 3542fcb

Please sign in to comment.