Skip to content

Commit 8b74895

Browse files
committed
fix(client)!: hostname and apiPath now a public attributes
1 parent e7634c8 commit 8b74895

File tree

9 files changed

+46
-46
lines changed

9 files changed

+46
-46
lines changed

v2/api/ca_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestClient_GetCAList(t *testing.T) {
2323
for _, tt := range tests {
2424
t.Run(tt.name, func(t *testing.T) {
2525
c := &Client{
26-
hostname: tt.fields.hostname,
26+
Hostname: tt.fields.hostname,
2727
httpClient: tt.fields.httpClient,
2828
basicAuthString: tt.fields.basicAuthString,
2929
}

v2/api/certificate_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package api
88
//
99
//func TestClient_DeployPFXCertificate(t *testing.T) {
1010
// type fields struct {
11-
// hostname string
11+
// Hostname string
1212
// httpClient *http.Client
1313
// basicAuthString string
1414
// }
@@ -27,7 +27,7 @@ package api
2727
// for _, tt := range tests {
2828
// t.Run(tt.name, func(t *testing.T) {
2929
// c := &Client{
30-
// hostname: tt.fields.hostname,
30+
// Hostname: tt.fields.Hostname,
3131
// httpClient: tt.fields.httpClient,
3232
// basicAuthString: tt.fields.basicAuthString,
3333
// }
@@ -45,7 +45,7 @@ package api
4545
//
4646
//func TestClient_DownloadCertificate(t *testing.T) {
4747
// type fields struct {
48-
// hostname string
48+
// Hostname string
4949
// httpClient *http.Client
5050
// basicAuthString string
5151
// }
@@ -68,7 +68,7 @@ package api
6868
// for _, tt := range tests {
6969
// t.Run(tt.name, func(t *testing.T) {
7070
// c := &Client{
71-
// hostname: tt.fields.hostname,
71+
// Hostname: tt.fields.Hostname,
7272
// httpClient: tt.fields.httpClient,
7373
// basicAuthString: tt.fields.basicAuthString,
7474
// }
@@ -89,7 +89,7 @@ package api
8989
//
9090
//func TestClient_EnrollCSR(t *testing.T) {
9191
// type fields struct {
92-
// hostname string
92+
// Hostname string
9393
// httpClient *http.Client
9494
// basicAuthString string
9595
// }
@@ -108,7 +108,7 @@ package api
108108
// for _, tt := range tests {
109109
// t.Run(tt.name, func(t *testing.T) {
110110
// c := &Client{
111-
// hostname: tt.fields.hostname,
111+
// Hostname: tt.fields.Hostname,
112112
// httpClient: tt.fields.httpClient,
113113
// basicAuthString: tt.fields.basicAuthString,
114114
// }
@@ -126,7 +126,7 @@ package api
126126
//
127127
//func TestClient_EnrollPFX(t *testing.T) {
128128
// type fields struct {
129-
// hostname string
129+
// Hostname string
130130
// httpClient *http.Client
131131
// basicAuthString string
132132
// }
@@ -145,7 +145,7 @@ package api
145145
// for _, tt := range tests {
146146
// t.Run(tt.name, func(t *testing.T) {
147147
// c := &Client{
148-
// hostname: tt.fields.hostname,
148+
// Hostname: tt.fields.Hostname,
149149
// httpClient: tt.fields.httpClient,
150150
// basicAuthString: tt.fields.basicAuthString,
151151
// }
@@ -163,7 +163,7 @@ package api
163163
//
164164
//func TestClient_GetCertificateContext(t *testing.T) {
165165
// type fields struct {
166-
// hostname string
166+
// Hostname string
167167
// httpClient *http.Client
168168
// basicAuthString string
169169
// }
@@ -182,7 +182,7 @@ package api
182182
// for _, tt := range tests {
183183
// t.Run(tt.name, func(t *testing.T) {
184184
// c := &Client{
185-
// hostname: tt.fields.hostname,
185+
// Hostname: tt.fields.Hostname,
186186
// httpClient: tt.fields.httpClient,
187187
// basicAuthString: tt.fields.basicAuthString,
188188
// }
@@ -200,7 +200,7 @@ package api
200200
//
201201
//func TestClient_RecoverCertificate(t *testing.T) {
202202
// type fields struct {
203-
// hostname string
203+
// Hostname string
204204
// httpClient *http.Client
205205
// basicAuthString string
206206
// }
@@ -225,7 +225,7 @@ package api
225225
// for _, tt := range tests {
226226
// t.Run(tt.name, func(t *testing.T) {
227227
// c := &Client{
228-
// hostname: tt.fields.hostname,
228+
// Hostname: tt.fields.Hostname,
229229
// httpClient: tt.fields.httpClient,
230230
// basicAuthString: tt.fields.basicAuthString,
231231
// }
@@ -249,7 +249,7 @@ package api
249249
//
250250
//func TestClient_RevokeCert(t *testing.T) {
251251
// type fields struct {
252-
// hostname string
252+
// Hostname string
253253
// httpClient *http.Client
254254
// basicAuthString string
255255
// }
@@ -267,7 +267,7 @@ package api
267267
// for _, tt := range tests {
268268
// t.Run(tt.name, func(t *testing.T) {
269269
// c := &Client{
270-
// hostname: tt.fields.hostname,
270+
// Hostname: tt.fields.Hostname,
271271
// httpClient: tt.fields.httpClient,
272272
// basicAuthString: tt.fields.basicAuthString,
273273
// }

v2/api/client.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ var (
2626
)
2727

2828
type Client struct {
29-
hostname string
29+
Hostname string
3030
httpClient *http.Client
3131
basicAuthString string
32-
apiPath string
32+
ApiPath string
3333
}
3434

3535
// AuthConfig is a struct holding all necessary client configuration data
36-
// for communicating with the Keyfactor API. This includes the hostname,
36+
// for communicating with the Keyfactor API. This includes the Hostname,
3737
// username, password, and domain.
3838
type AuthConfig struct {
3939
Hostname string
@@ -112,18 +112,18 @@ func loginToKeyfactor(auth *AuthConfig) (*Client, error) {
112112
}
113113

114114
c := &Client{
115-
hostname: auth.Hostname,
115+
Hostname: auth.Hostname,
116116
httpClient: &http.Client{Timeout: 10 * time.Second},
117117
basicAuthString: buildBasicAuthString(auth),
118-
apiPath: auth.APIPath,
118+
ApiPath: auth.APIPath,
119119
}
120120

121121
_, err := c.sendRequest(keyfactorAPIStruct)
122122
if err != nil {
123123
return nil, err
124124
}
125125

126-
log.Printf("[INFO] Successfully logged into Keyfactor at host %s", c.hostname)
126+
log.Printf("[INFO] Successfully logged into Keyfactor at host %s", c.Hostname)
127127

128128
return c, nil
129129
}
@@ -135,14 +135,14 @@ func (c *Client) sendRequest(request *request) (*http.Response, error) {
135135
if c == nil {
136136
return nil, errors.New("invalid Keyfactor client, please check your configuration")
137137
}
138-
u, err := url.Parse(c.hostname) // Parse raw hostname into URL structure
138+
u, err := url.Parse(c.Hostname) // Parse raw Hostname into URL structure
139139
if err != nil {
140140
return nil, err
141141
}
142142
if u.Scheme != "https" {
143143
u.Scheme = "https"
144144
}
145-
endpoint := fmt.Sprintf("%s/", strings.Trim(c.apiPath, "/")) + request.Endpoint
145+
endpoint := fmt.Sprintf("%s/", strings.Trim(c.ApiPath, "/")) + request.Endpoint
146146
u.Path = path.Join(u.Path, endpoint) // Attach enroll endpoint
147147

148148
// Set request query

v2/api/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestClient_sendRequest(t *testing.T) {
2727
for _, tt := range tests {
2828
t.Run(tt.name, func(t *testing.T) {
2929
c := &Client{
30-
hostname: tt.fields.hostname,
30+
Hostname: tt.fields.hostname,
3131
httpClient: tt.fields.httpClient,
3232
basicAuthString: tt.fields.basicAuthString,
3333
}

v2/api/metadata_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestClient_GetAllMetadataFields(t *testing.T) {
2323
for _, tt := range tests {
2424
t.Run(tt.name, func(t *testing.T) {
2525
c := &Client{
26-
hostname: tt.fields.hostname,
26+
Hostname: tt.fields.hostname,
2727
httpClient: tt.fields.httpClient,
2828
basicAuthString: tt.fields.basicAuthString,
2929
}
@@ -59,7 +59,7 @@ func TestClient_UpdateMetadata(t *testing.T) {
5959
for _, tt := range tests {
6060
t.Run(tt.name, func(t *testing.T) {
6161
c := &Client{
62-
hostname: tt.fields.hostname,
62+
Hostname: tt.fields.hostname,
6363
httpClient: tt.fields.httpClient,
6464
basicAuthString: tt.fields.basicAuthString,
6565
}

v2/api/security_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestClient_CreateSecurityIdentity(t *testing.T) {
2727
for _, tt := range tests {
2828
t.Run(tt.name, func(t *testing.T) {
2929
c := &Client{
30-
hostname: tt.fields.hostname,
30+
Hostname: tt.fields.hostname,
3131
httpClient: tt.fields.httpClient,
3232
basicAuthString: tt.fields.basicAuthString,
3333
}
@@ -64,7 +64,7 @@ func TestClient_CreateSecurityRole(t *testing.T) {
6464
for _, tt := range tests {
6565
t.Run(tt.name, func(t *testing.T) {
6666
c := &Client{
67-
hostname: tt.fields.hostname,
67+
Hostname: tt.fields.hostname,
6868
httpClient: tt.fields.httpClient,
6969
basicAuthString: tt.fields.basicAuthString,
7070
}
@@ -100,7 +100,7 @@ func TestClient_DeleteSecurityIdentity(t *testing.T) {
100100
for _, tt := range tests {
101101
t.Run(tt.name, func(t *testing.T) {
102102
c := &Client{
103-
hostname: tt.fields.hostname,
103+
Hostname: tt.fields.hostname,
104104
httpClient: tt.fields.httpClient,
105105
basicAuthString: tt.fields.basicAuthString,
106106
}
@@ -131,7 +131,7 @@ func TestClient_DeleteSecurityRole(t *testing.T) {
131131
for _, tt := range tests {
132132
t.Run(tt.name, func(t *testing.T) {
133133
c := &Client{
134-
hostname: tt.fields.hostname,
134+
Hostname: tt.fields.hostname,
135135
httpClient: tt.fields.httpClient,
136136
basicAuthString: tt.fields.basicAuthString,
137137
}
@@ -159,7 +159,7 @@ func TestClient_GetSecurityIdentities(t *testing.T) {
159159
for _, tt := range tests {
160160
t.Run(tt.name, func(t *testing.T) {
161161
c := &Client{
162-
hostname: tt.fields.hostname,
162+
Hostname: tt.fields.hostname,
163163
httpClient: tt.fields.httpClient,
164164
basicAuthString: tt.fields.basicAuthString,
165165
}
@@ -196,7 +196,7 @@ func TestClient_GetSecurityRole(t *testing.T) {
196196
for _, tt := range tests {
197197
t.Run(tt.name, func(t *testing.T) {
198198
c := &Client{
199-
hostname: tt.fields.hostname,
199+
Hostname: tt.fields.hostname,
200200
httpClient: tt.fields.httpClient,
201201
basicAuthString: tt.fields.basicAuthString,
202202
}
@@ -229,7 +229,7 @@ func TestClient_GetSecurityRoles(t *testing.T) {
229229
for _, tt := range tests {
230230
t.Run(tt.name, func(t *testing.T) {
231231
c := &Client{
232-
hostname: tt.fields.hostname,
232+
Hostname: tt.fields.hostname,
233233
httpClient: tt.fields.httpClient,
234234
basicAuthString: tt.fields.basicAuthString,
235235
}
@@ -266,7 +266,7 @@ func TestClient_UpdateSecurityRole(t *testing.T) {
266266
for _, tt := range tests {
267267
t.Run(tt.name, func(t *testing.T) {
268268
c := &Client{
269-
hostname: tt.fields.hostname,
269+
Hostname: tt.fields.hostname,
270270
httpClient: tt.fields.httpClient,
271271
basicAuthString: tt.fields.basicAuthString,
272272
}

v2/api/store_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestClient_AddCertificateToStores(t *testing.T) {
2727
for _, tt := range tests {
2828
t.Run(tt.name, func(t *testing.T) {
2929
c := &Client{
30-
hostname: tt.fields.hostname,
30+
Hostname: tt.fields.hostname,
3131
httpClient: tt.fields.httpClient,
3232
basicAuthString: tt.fields.basicAuthString,
3333
}
@@ -64,7 +64,7 @@ func TestClient_CreateStore(t *testing.T) {
6464
for _, tt := range tests {
6565
t.Run(tt.name, func(t *testing.T) {
6666
c := &Client{
67-
hostname: tt.fields.hostname,
67+
Hostname: tt.fields.hostname,
6868
httpClient: tt.fields.httpClient,
6969
basicAuthString: tt.fields.basicAuthString,
7070
}
@@ -100,7 +100,7 @@ func TestClient_DeleteCertificateStore(t *testing.T) {
100100
for _, tt := range tests {
101101
t.Run(tt.name, func(t *testing.T) {
102102
c := &Client{
103-
hostname: tt.fields.hostname,
103+
Hostname: tt.fields.hostname,
104104
httpClient: tt.fields.httpClient,
105105
basicAuthString: tt.fields.basicAuthString,
106106
}
@@ -132,7 +132,7 @@ func TestClient_GetCertStoreInventory(t *testing.T) {
132132
for _, tt := range tests {
133133
t.Run(tt.name, func(t *testing.T) {
134134
c := &Client{
135-
hostname: tt.fields.hostname,
135+
Hostname: tt.fields.hostname,
136136
httpClient: tt.fields.httpClient,
137137
basicAuthString: tt.fields.basicAuthString,
138138
}
@@ -169,7 +169,7 @@ func TestClient_GetCertificateStoreByID(t *testing.T) {
169169
for _, tt := range tests {
170170
t.Run(tt.name, func(t *testing.T) {
171171
c := &Client{
172-
hostname: tt.fields.hostname,
172+
Hostname: tt.fields.hostname,
173173
httpClient: tt.fields.httpClient,
174174
basicAuthString: tt.fields.basicAuthString,
175175
}
@@ -202,7 +202,7 @@ func TestClient_ListCertificateStores(t *testing.T) {
202202
for _, tt := range tests {
203203
t.Run(tt.name, func(t *testing.T) {
204204
c := &Client{
205-
hostname: tt.fields.hostname,
205+
Hostname: tt.fields.hostname,
206206
httpClient: tt.fields.httpClient,
207207
basicAuthString: tt.fields.basicAuthString,
208208
}
@@ -239,7 +239,7 @@ func TestClient_RemoveCertificateFromStores(t *testing.T) {
239239
for _, tt := range tests {
240240
t.Run(tt.name, func(t *testing.T) {
241241
c := &Client{
242-
hostname: tt.fields.hostname,
242+
Hostname: tt.fields.hostname,
243243
httpClient: tt.fields.httpClient,
244244
basicAuthString: tt.fields.basicAuthString,
245245
}
@@ -276,7 +276,7 @@ func TestClient_UpdateStore(t *testing.T) {
276276
for _, tt := range tests {
277277
t.Run(tt.name, func(t *testing.T) {
278278
c := &Client{
279-
hostname: tt.fields.hostname,
279+
Hostname: tt.fields.hostname,
280280
httpClient: tt.fields.httpClient,
281281
basicAuthString: tt.fields.basicAuthString,
282282
}

v2/api/store_type_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type storeTypeTestArgs struct {
2222
name string
2323
}
2424
type storeTypeTestFields struct {
25-
//hostname string
25+
//Hostname string
2626
//httpClient *http.Client
2727
//basicAuthString string
2828
}

v2/api/template_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestClient_GetTemplate(t *testing.T) {
2727
for _, tt := range tests {
2828
t.Run(tt.name, func(t *testing.T) {
2929
c := &Client{
30-
hostname: tt.fields.hostname,
30+
Hostname: tt.fields.hostname,
3131
httpClient: tt.fields.httpClient,
3232
basicAuthString: tt.fields.basicAuthString,
3333
}
@@ -60,7 +60,7 @@ func TestClient_GetTemplates(t *testing.T) {
6060
for _, tt := range tests {
6161
t.Run(tt.name, func(t *testing.T) {
6262
c := &Client{
63-
hostname: tt.fields.hostname,
63+
Hostname: tt.fields.hostname,
6464
httpClient: tt.fields.httpClient,
6565
basicAuthString: tt.fields.basicAuthString,
6666
}
@@ -97,7 +97,7 @@ func TestClient_UpdateTemplate(t *testing.T) {
9797
for _, tt := range tests {
9898
t.Run(tt.name, func(t *testing.T) {
9999
c := &Client{
100-
hostname: tt.fields.hostname,
100+
Hostname: tt.fields.hostname,
101101
httpClient: tt.fields.httpClient,
102102
basicAuthString: tt.fields.basicAuthString,
103103
}

0 commit comments

Comments
 (0)