@@ -185,10 +185,10 @@ func TestIdentityStore_UnsealingWhenConflictingAliasNames(t *testing.T) {
185185func TestIdentityStore_EntityIDPassthrough (t * testing.T ) {
186186 // Enable AppRole auth and initialize
187187 ctx := namespace .RootContext (nil )
188- is , ghAccessor , core := testIdentityStoreWithAppRoleAuth (ctx , t )
188+ is , approleAccessor , core := testIdentityStoreWithAppRoleAuth (ctx , t )
189189 alias := & logical.Alias {
190190 MountType : "approle" ,
191- MountAccessor : ghAccessor ,
191+ MountAccessor : approleAccessor ,
192192 Name : "approleuser" ,
193193 }
194194
@@ -257,12 +257,21 @@ func TestIdentityStore_EntityIDPassthrough(t *testing.T) {
257257}
258258
259259func TestIdentityStore_CreateOrFetchEntity (t * testing.T ) {
260- ctx := namespace .RootContext (nil )
261- is , ghAccessor , upAccessor , _ := testIdentityStoreWithAppRoleUserpassAuth (ctx , t )
260+ ctx := namespace .RootContext (t .Context ())
261+ is , approleAccessor , upAccessor , core := testIdentityStoreWithAppRoleUserpassAuth (ctx , t , false )
262+ testIdentityStoreCreateOrFetchEntity (t , ctx , is , approleAccessor , upAccessor , core )
263+ }
262264
265+ func TestIdentityStore_CreateOrFetchEntity_UnsafeShared (t * testing.T ) {
266+ ctx := namespace .RootContext (t .Context ())
267+ is , approleAccessor , upAccessor , core := testIdentityStoreWithAppRoleUserpassAuth (ctx , t , true )
268+ testIdentityStoreCreateOrFetchEntity (t , ctx , is , approleAccessor , upAccessor , core )
269+ }
270+
271+ func testIdentityStoreCreateOrFetchEntity (t * testing.T , ctx context.Context , is * IdentityStore , approleAccessor string , upAccessor string , core * Core ) {
263272 alias := & logical.Alias {
264273 MountType : "approle" ,
265- MountAccessor : ghAccessor ,
274+ MountAccessor : approleAccessor ,
266275 Name : "approleuser" ,
267276 Metadata : map [string ]string {
268277 "foo" : "a" ,
@@ -372,7 +381,7 @@ func TestIdentityStore_EntityByAliasFactors(t *testing.T) {
372381 var resp * logical.Response
373382
374383 ctx := namespace .RootContext (nil )
375- is , ghAccessor , _ := testIdentityStoreWithAppRoleAuth (ctx , t )
384+ is , approleAccessor , _ := testIdentityStoreWithAppRoleAuth (ctx , t )
376385
377386 registerData := map [string ]interface {}{
378387 "name" : "testentityname" ,
@@ -403,7 +412,7 @@ func TestIdentityStore_EntityByAliasFactors(t *testing.T) {
403412 aliasData := map [string ]interface {}{
404413 "entity_id" : entityID ,
405414 "name" : "alias_name" ,
406- "mount_accessor" : ghAccessor ,
415+ "mount_accessor" : approleAccessor ,
407416 }
408417 aliasReq := & logical.Request {
409418 Operation : logical .UpdateOperation ,
@@ -419,7 +428,7 @@ func TestIdentityStore_EntityByAliasFactors(t *testing.T) {
419428 t .Fatal ("expected a non-nil response" )
420429 }
421430
422- entity , err := is .entityByAliasFactors (ctx , ghAccessor , "alias_name" , false )
431+ entity , err := is .entityByAliasFactors (ctx , approleAccessor , "alias_name" , false )
423432 if err != nil {
424433 t .Fatal (err )
425434 }
@@ -648,13 +657,13 @@ func TestIdentityStore_MergeConflictingAliases(t *testing.T) {
648657}
649658
650659func testCoreWithIdentityTokenAppRole (ctx context.Context , t * testing.T ) (* Core , * IdentityStore , * TokenStore , string ) {
651- is , ghAccessor , core := testIdentityStoreWithAppRoleAuth (ctx , t )
652- return core , is , core .tokenStore , ghAccessor
660+ is , approleAccessor , core := testIdentityStoreWithAppRoleAuth (ctx , t )
661+ return core , is , core .tokenStore , approleAccessor
653662}
654663
655664func testCoreWithIdentityTokenAppRoleRoot (ctx context.Context , t * testing.T ) (* Core , * IdentityStore , * TokenStore , string , string ) {
656- is , ghAccessor , core , root := testIdentityStoreWithAppRoleAuthRoot (ctx , t )
657- return core , is , core .tokenStore , ghAccessor , root
665+ is , approleAccessor , core , root := testIdentityStoreWithAppRoleAuthRoot (ctx , t )
666+ return core , is , core .tokenStore , approleAccessor , root
658667}
659668
660669func testIdentityStoreWithAppRoleAuth (ctx context.Context , t * testing.T ) (* IdentityStore , string , * Core ) {
@@ -692,7 +701,7 @@ func testIdentityStoreWithAppRoleAuthRoot(ctx context.Context, t *testing.T) (*I
692701 return c .identityStore , meGH .Accessor , c , root
693702}
694703
695- func testIdentityStoreWithAppRoleUserpassAuth (ctx context.Context , t * testing.T ) (* IdentityStore , string , string , * Core ) {
704+ func testIdentityStoreWithAppRoleUserpassAuth (ctx context.Context , t * testing.T , unsafeShared bool ) (* IdentityStore , string , string , * Core ) {
696705 // Setup 2 auth backends, github and userpass
697706 err := AddTestCredentialBackend ("approle" , credAppRole .Factory )
698707 if err != nil {
@@ -706,7 +715,14 @@ func testIdentityStoreWithAppRoleUserpassAuth(ctx context.Context, t *testing.T)
706715
707716 defer ClearTestCredentialBackends ()
708717
709- c , _ , _ := TestCoreUnsealed (t )
718+ conf := & CoreConfig {
719+ BuiltinRegistry : corehelpers .NewMockBuiltinRegistry (),
720+ UnsafeCrossNamespaceIdentity : unsafeShared ,
721+ AuditBackends : map [string ]audit.Factory {
722+ "file" : auditFile .Factory ,
723+ },
724+ }
725+ c , _ , _ := TestCoreUnsealedWithConfig (t , conf )
710726
711727 githubMe := & MountEntry {
712728 Table : credentialTableType ,
@@ -802,11 +818,11 @@ func TestIdentityStore_NewEntityCounter(t *testing.T) {
802818 }
803819
804820 is := c .identityStore
805- ghAccessor := meGH .Accessor
821+ approleAccessor := meGH .Accessor
806822
807823 alias := & logical.Alias {
808824 MountType : "approle" ,
809- MountAccessor : ghAccessor ,
825+ MountAccessor : approleAccessor ,
810826 Name : "approleuser" ,
811827 Metadata : map [string ]string {
812828 "foo" : "a" ,
0 commit comments