Skip to content

Commit

Permalink
Added and updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jul 28, 2023
1 parent e8a394e commit 030c1be
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestDefaultService(t *testing.T) {

_, ofgaClient, cfg, err := jimmtest.SetupTestOFGAClient(c.Name())
c.Assert(err, qt.IsNil)

os.Setenv("INSECURE_SECRET_STORAGE", "enable")
svc, err := jimm.NewService(context.Background(), jimm.Params{
OpenFGAParams: jimm.OpenFGAParams{
Scheme: cfg.ApiScheme,
Expand All @@ -62,6 +62,23 @@ func TestDefaultService(t *testing.T) {
c.Check(resp.StatusCode, qt.Equals, http.StatusOK)
}

func TestServiceFailsToStartWithoutSecretStore(t *testing.T) {
c := qt.New(t)

_, ofgaClient, cfg, err := jimmtest.SetupTestOFGAClient(c.Name())
c.Assert(err, qt.IsNil)
_, err = jimm.NewService(context.Background(), jimm.Params{
OpenFGAParams: jimm.OpenFGAParams{
Scheme: cfg.ApiScheme,
Host: cfg.ApiHost,
Store: cfg.StoreId,
Token: cfg.Credentials.Config.ApiToken,
AuthModel: ofgaClient.AuthModelId,
},
})
c.Assert(err, qt.ErrorMatches, "no credential store setup")
}

func TestAuthenticator(t *testing.T) {
c := qt.New(t)

Expand All @@ -80,6 +97,7 @@ func TestAuthenticator(t *testing.T) {
},
}
candid := startCandid(c, &p)
os.Setenv("INSECURE_SECRET_STORAGE", "enable")
svc, err := jimm.NewService(context.Background(), p)
c.Assert(err, qt.IsNil)

Expand Down Expand Up @@ -187,6 +205,27 @@ func TestVault(t *testing.T) {
})
}

func TestPostgresSecretStore(t *testing.T) {
c := qt.New(t)

_, ofgaClient, cfg, err := jimmtest.SetupTestOFGAClient(c.Name())
c.Assert(err, qt.IsNil)

p := jimm.Params{
ControllerUUID: "6acf4fd8-32d6-49ea-b4eb-dcb9d1590c11",
OpenFGAParams: jimm.OpenFGAParams{
Scheme: cfg.ApiScheme,
Host: cfg.ApiHost,
Store: cfg.StoreId,
Token: cfg.Credentials.Config.ApiToken,
AuthModel: ofgaClient.AuthModelId,
},
}
os.Setenv("INSECURE_SECRET_STORAGE", "enable")
_, err = jimm.NewService(context.Background(), p)
c.Assert(err, qt.IsNil)
}

func TestOpenFGA(t *testing.T) {
c := qt.New(t)

Expand Down

0 comments on commit 030c1be

Please sign in to comment.