Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Included additional zia and zpa integration tests #197

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions zia/services/adminuserrolemgmt/admins/admin_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,55 @@ func tryRetrieveResource(s *Service, id int) (*AdminUsers, error) {

return nil, err
}

func TestRetrieveNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.GetAdminUsers(0)
if err == nil {
t.Error("Expected error retrieving non-existent resource, but got nil")
}
}

func TestDeleteNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.DeleteAdminUser(0)
if err == nil {
t.Error("Expected error deleting non-existent resource, but got nil")
}
}

func TestUpdateNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.UpdateAdminUser(0, AdminUsers{})
if err == nil {
t.Error("Expected error updating non-existent resource, but got nil")
}
}

func TestGetByNameNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.GetAdminByUsername("non-existent-name")
if err == nil {
t.Error("Expected error retrieving resource by non-existent name, but got nil")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,55 @@ func tryRetrieveResource(s *Service, id int) (*DLPEngines, error) {

return nil, err
}

func TestRetrieveNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Get(0)
if err == nil {
t.Error("Expected error retrieving non-existent resource, but got nil")
}
}

func TestDeleteNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Delete(0)
if err == nil {
t.Error("Expected error deleting non-existent resource, but got nil")
}
}

func TestUpdateNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, _, err = service.Update(0, &DLPEngines{})
if err == nil {
t.Error("Expected error updating non-existent resource, but got nil")
}
}

func TestGetByNameNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.GetByName("non-existent-name")
if err == nil {
t.Error("Expected error retrieving resource by non-existent name, but got nil")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,55 @@ func tryRetrieveResource(s *Service, id int) (*DlpNotificationTemplates, error)

return nil, err
}

func TestRetrieveNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Get(0)
if err == nil {
t.Error("Expected error retrieving non-existent resource, but got nil")
}
}

func TestDeleteNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Delete(0)
if err == nil {
t.Error("Expected error deleting non-existent resource, but got nil")
}
}

func TestUpdateNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, _, err = service.Update(0, &DlpNotificationTemplates{})
if err == nil {
t.Error("Expected error updating non-existent resource, but got nil")
}
}

func TestGetByNameNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.GetByName("non-existent-name")
if err == nil {
t.Error("Expected error retrieving resource by non-existent name, but got nil")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,55 @@ func tryRetrieveResource(s *Service, id int) (*WebDLPRules, error) {

return nil, err
}

func TestRetrieveNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Get(0)
if err == nil {
t.Error("Expected error retrieving non-existent resource, but got nil")
}
}

func TestDeleteNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Delete(0)
if err == nil {
t.Error("Expected error deleting non-existent resource, but got nil")
}
}

func TestUpdateNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Update(0, &WebDLPRules{})
if err == nil {
t.Error("Expected error updating non-existent resource, but got nil")
}
}

func TestGetByNameNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.GetByName("non-existent-name")
if err == nil {
t.Error("Expected error retrieving resource by non-existent name, but got nil")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,55 @@ func tryRetrieveResource(s *Service, id int) (*DlpDictionary, error) {

return nil, err
}

func TestRetrieveNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Get(0)
if err == nil {
t.Error("Expected error retrieving non-existent resource, but got nil")
}
}

func TestDeleteNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.DeleteDlpDictionary(0)
if err == nil {
t.Error("Expected error deleting non-existent resource, but got nil")
}
}

func TestUpdateNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, _, err = service.Update(0, &DlpDictionary{})
if err == nil {
t.Error("Expected error updating non-existent resource, but got nil")
}
}

func TestGetByNameNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.GetByName("non-existent-name")
if err == nil {
t.Error("Expected error retrieving resource by non-existent name, but got nil")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,55 @@ func tryRetrieveResource(s *Service, id int) (*FirewallFilteringRules, error) {

return nil, err
}

func TestRetrieveNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Get(0)
if err == nil {
t.Error("Expected error retrieving non-existent resource, but got nil")
}
}

func TestDeleteNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Delete(0)
if err == nil {
t.Error("Expected error deleting non-existent resource, but got nil")
}
}

func TestUpdateNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Update(0, &FirewallFilteringRules{})
if err == nil {
t.Error("Expected error updating non-existent resource, but got nil")
}
}

func TestGetByNameNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.GetByName("non-existent-name")
if err == nil {
t.Error("Expected error retrieving resource by non-existent name, but got nil")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,55 @@ func tryRetrieveResource(s *Service, id int) (*IPDestinationGroups, error) {

return nil, err
}

func TestRetrieveNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Get(0)
if err == nil {
t.Error("Expected error retrieving non-existent resource, but got nil")
}
}

func TestDeleteNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.Delete(0)
if err == nil {
t.Error("Expected error deleting non-existent resource, but got nil")
}
}

func TestUpdateNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, _, err = service.Update(0, &IPDestinationGroups{})
if err == nil {
t.Error("Expected error updating non-existent resource, but got nil")
}
}

func TestGetByNameNonExistentResource(t *testing.T) {
client, err := tests.NewZiaClient()
if err != nil {
t.Fatalf("Error creating client: %v", err)
}
service := New(client)

_, err = service.GetByName("non-existent-name")
if err == nil {
t.Error("Expected error retrieving resource by non-existent name, but got nil")
}
}
Loading
Loading