Skip to content

Commit

Permalink
Update tests and mock
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhung committed Dec 9, 2024
1 parent b040df5 commit d3af266
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,9 @@ func mockArtifactoryUsageVersionRequests(version string) {
httpmock.NewStringResponder(200, versionString))
}

func mockArtifactoryRoleRequest() {
func mockArtifactoryTokenRequest() {
httpmock.RegisterResponder(
http.MethodGet,
"http://myserver.com:80/access/api/v1/roles/Viewer",
"http://myserver.com:80/access/api/v1/tokens/me",
httpmock.NewStringResponder(200, ""))
}
14 changes: 7 additions & 7 deletions ttl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestBackend_NoUserTokensMaxTTLUsesSystemMaxTTL(t *testing.T) {
defer httpmock.DeactivateAndReset()

mockArtifactoryUsageVersionRequests("")
mockArtifactoryRoleRequest()
mockArtifactoryTokenRequest()

httpmock.RegisterResponder(
http.MethodPost,
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestBackend_UserTokenConfigMaxTTLUseSystem(t *testing.T) {
defer httpmock.DeactivateAndReset()

mockArtifactoryUsageVersionRequests("")
mockArtifactoryRoleRequest()
mockArtifactoryTokenRequest()

httpmock.RegisterResponder(
http.MethodPost,
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestBackend_UserTokenConfigMaxTTLUseConfigMaxTTL(t *testing.T) {
defer httpmock.DeactivateAndReset()

mockArtifactoryUsageVersionRequests("")
mockArtifactoryRoleRequest()
mockArtifactoryTokenRequest()

httpmock.RegisterResponder(
http.MethodPost,
Expand Down Expand Up @@ -242,7 +242,7 @@ func TestBackend_UserTokenMaxTTLUseRequestTTL(t *testing.T) {
defer httpmock.DeactivateAndReset()

mockArtifactoryUsageVersionRequests("")
mockArtifactoryRoleRequest()
mockArtifactoryTokenRequest()

httpmock.RegisterResponder(
http.MethodPost,
Expand Down Expand Up @@ -277,7 +277,7 @@ func TestBackend_UserTokenMaxTTLEnforced(t *testing.T) {
defer httpmock.DeactivateAndReset()

mockArtifactoryUsageVersionRequests("")
mockArtifactoryRoleRequest()
mockArtifactoryTokenRequest()

httpmock.RegisterResponder(
http.MethodPost,
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestBackend_UserTokenTTLRequest(t *testing.T) {
defer httpmock.DeactivateAndReset()

mockArtifactoryUsageVersionRequests("")
mockArtifactoryRoleRequest()
mockArtifactoryTokenRequest()

httpmock.RegisterResponder(
http.MethodPost,
Expand Down Expand Up @@ -345,7 +345,7 @@ func TestBackend_UserTokenDefaultTTL(t *testing.T) {
defer httpmock.DeactivateAndReset()

mockArtifactoryUsageVersionRequests("")
mockArtifactoryRoleRequest()
mockArtifactoryTokenRequest()

httpmock.RegisterResponder(
http.MethodPost,
Expand Down

0 comments on commit d3af266

Please sign in to comment.