Skip to content

Commit 2cebf7e

Browse files
authored
Fix NOT_AUTHENTICATED errors in Content Library tests (#53)
Signed-off-by: abarreiro <abarreiro@vmware.com>
1 parent fdab1c4 commit 2cebf7e

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

.changes/v1.0.0/12-features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- **New Resource:** `vcfa_content_library` to manage Content Libraries [GH-12, GH-42, GH-43, GH-50]
2-
- **New Data Source:** `vcfa_content_library` to read Content Libraries [GH-12, GH-42, GH-50]
1+
- **New Resource:** `vcfa_content_library` to manage Content Libraries [GH-12, GH-42, GH-43, GH-50, GH-53]
2+
- **New Data Source:** `vcfa_content_library` to read Content Libraries [GH-12, GH-42, GH-50, GH-53]
33
- **New Data Source:** `vcfa_region_storage_policy` to read Region Storage Policies [GH-12]
44
- **New Data Source:** `vcfa_storage_class` to read Storage Classes [GH-12]

.changes/v1.0.0/13-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
* **New Resource:** `vcfa_content_library_item` to manage Content Library Items [GH-13, GH-46, GH-50]
1+
* **New Resource:** `vcfa_content_library_item` to manage Content Library Items [GH-13, GH-46, GH-50, GH-53]
22
* **New Data Source:** `vcfa_content_library_item` to read Content Library Items [GH-13]

vcfa/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ type cacheStorage struct {
7272
sync.Mutex
7373
}
7474

75+
// reset clears cache to force re-authentication
76+
func (c *cacheStorage) reset() {
77+
c.Lock()
78+
defer c.Unlock()
79+
c.cacheClientServedCount = 0
80+
c.conMap = make(map[string]cachedConnection)
81+
}
82+
7583
var (
7684
// Enables the caching of authenticated connections
7785
enableConnectionCache = os.Getenv("VCFA_CACHE") != ""

vcfa/resource_vcfa_content_library_item_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ func TestAccVcfaContentLibraryItemTenant(t *testing.T) {
261261
}
262262
}
263263

264+
// Before this test ends we need to clean up the clients cache, because we create an Org user
265+
// and use it to login with the provider. Using same credentials and org name could lead to errors if this user
266+
// remains cached.
267+
defer cachedVCDClients.reset()
268+
264269
resource.Test(t, resource.TestCase{
265270
Steps: []resource.TestStep{
266271
{

vcfa/resource_vcfa_content_library_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ func TestAccVcfaContentLibraryTenant(t *testing.T) {
282282
}
283283
}
284284

285+
// Before this test ends we need to clean up the clients cache, because we create an Org user
286+
// and use it to login with the provider. Using same credentials and org name could lead to errors if this user
287+
// remains cached.
288+
defer cachedVCDClients.reset()
289+
285290
resource.Test(t, resource.TestCase{
286291
Steps: []resource.TestStep{
287292
{
@@ -423,7 +428,7 @@ resource "vcfa_org" "test" {
423428
resource "vcfa_org_settings" "allow" {
424429
org_id = vcfa_org.test.id
425430
can_create_subscribed_libraries = true
426-
quarantine_content_library_items = true
431+
quarantine_content_library_items = false
427432
}
428433
429434
data "vcfa_role" "org-admin" {

0 commit comments

Comments
 (0)