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

Associate project for every organisation fetched #6518

Closed
wants to merge 133 commits into from

Conversation

YashviJain01
Copy link
Collaborator

@YashviJain01 YashviJain01 commented Jan 6, 2022

🔩 Description: What code changed, and why?

When a organisation is migrated from the chef server to automate, an IAM project needs to be linked with it.
So added the call to project create service to create the project with the name of serverId_orgID, every time the organisation is stored in the database the project is created with the name having all the policies as editors, viewer, owner.

⛓️ Related Resources

👍 Definition of Done

Project is created and stored in database at the time of migration

👟 How to Build and Test the Change

Steps to build:

rebuild components/infra-proxy-service
rebuild components/automate-gateway

Steps to test:

  1. Ensure Chef Infra Server is running. If it is not start it with start_chef_server
  2. Add the chef-server test environment credentials and extract the SERVER IDs

Request
This is a get request.
curl -sSkH "api-token: $(get_admin_token)" 'https://a2-dev.test/api/v0/infra/servers/SERVER_ID/infraserverorgs'

Response

{
    "orgs": [
        {
            "id": "test",
            "name": "test",
            "admin_user": "",
            "credential_id": "",
            "server_id": "serverId",
            "projects": ["serverID_test"]
        }
    ]
}

✅ Checklist

All PRs must tick these:

With occasional exceptions, all PRs from Progress employees must tick these:

  • Is the code clear? (complicated code or lots of comments--subdivide and use well-named methods, meaningful variable names, etc.)
  • Consistency checked? (user notifications, user prompts, visual patterns, code patterns, variable names)
  • Repeated code blocks eliminated? (adapt and reuse existing components, blocks, functions, etc.)
  • Spelling, grammar, typos checked? (at a minimum use make spell in any component directory)
  • Code well-formatted? (indents, line breaks, etc. improve rather than hinder readability)

All PRs from Progress employees should tick these if appropriate:

  • Tests added/updated? (all new code needs new tests)
  • Docs added/updated? (all customer-facing changes)

Please add a note next to any checkbox above if you are NOT ticking it.

📷 Screenshots, if applicable

@YashviJain01 YashviJain01 added automate-infra-proxy-api using for automate infra proxy backend api's Team: Stalwart Migrate Chef Manage, UI bugs, UX improvements, CVE Issues infra-user-mgnt labels Jan 6, 2022
@YashviJain01 YashviJain01 self-assigned this Jan 6, 2022
@m0dul3
Copy link

m0dul3 commented Jan 6, 2022

a

sonali523 and others added 22 commits January 7, 2022 15:14
* Script added for table 'users'

Signed-off-by: root <swale@msystechnologies.com>

* updated down script

Signed-off-by: root <swale@msystechnologies.com>

* updated up script

Signed-off-by: root <swale@msystechnologies.com>

* updated up script

Signed-off-by: root <swale@msystechnologies.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
…hen doing builds (#5741)

Signed-off-by: Rick Marry <rmarry@chef.io>
Signed-off-by: root <swale@msystechnologies.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
* Storage functions added for users table

Signed-off-by: root <swale@msystechnologies.com>

* Updated with review comments

Signed-off-by: root <swale@msystechnologies.com>
* converted server modal into slider

Signed-off-by: chaitali-mane <cmane@progress.com>

* Updated test cases

Signed-off-by: chaitali-mane <cmane@progress.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
* converted server modal into slider

Signed-off-by: chaitali-mane <cmane@progress.com>

* Updated test cases

Signed-off-by: chaitali-mane <cmane@progress.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
* added some changes for the create server slider

Signed-off-by: Vinay Sharma <vsharma@chef.io>

* added some minor changes

Signed-off-by: Vinay Sharma <vsharma@chef.io>
Signed-off-by: Abdul-Az <aazeez@progress.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
Signed-off-by: Abdul-Az <aazeez@progress.com>
Signed-off-by: root <swale@msystechnologies.com>
* Added Users tab UI

Signed-off-by: chaitali-mane <cmane@progress.com>

* Added enitites api integration

Signed-off-by: chaitali-mane <cmane@progress.com>

* minor changes

Signed-off-by: chaitali-mane <cmane@progress.com>

* Updated minor change

Signed-off-by: chaitali-mane <cmane@progress.com>
Signed-off-by: Himanshi Chhabra <hchhabra@progress.com>
* Shell script added to add the sample infra server users

Signed-off-by: root <swale@msystechnologies.com>

* Minor changes added

Signed-off-by: root <swale@msystechnologies.com>
Signed-off-by: Kallol Roy <karoy@progress.com>
* Script added for migration tables

Signed-off-by: sonali wale <sonali.wale@progress.com>

* Insert scripts added for migration type and status

Signed-off-by: sonali wale <sonali.wale@progress.com>

* Server id column added in migration table

Signed-off-by: sonali wale <sonali.wale@progress.com>

* Index added on server_id column in migration table

Signed-off-by: sonali wale <sonali.wale@progress.com>
@vinay033 vinay033 force-pushed the feature/infra_user_management branch from 30b5842 to eca1a1b Compare January 7, 2022 09:45
@YashviJain01 YashviJain01 marked this pull request as draft January 10, 2022 04:47
@YashviJain01 YashviJain01 requested review from sonali523, kalroy and vinay033 and removed request for sonali523 January 10, 2022 05:24
@YashviJain01 YashviJain01 marked this pull request as ready for review January 10, 2022 05:31
* editor actions added

Signed-off-by: Abdul-Az <aazeez@progress.com>

* infra_editor test cases

Signed-off-by: Abdul-Az <aazeez@progress.com>

* test cases fix

Signed-off-by: Abdul-Az <aazeez@progress.com>

* infra editor actions update

Signed-off-by: Abdul-Az <aazeez@progress.com>

* editor role fix

Signed-off-by: Abdul-Az <aazeez@progress.com>

* test cases fix

Signed-off-by: Abdul-Az <aazeez@progress.com>
* project owner wip

Signed-off-by: Abdul-Az <aazeez@progress.com>

* project owner actions

Signed-off-by: Abdul-Az <aazeez@progress.com>

* fix

Signed-off-by: Abdul-Az <aazeez@progress.com>

* doc update

Signed-off-by: Abdul-Az <aazeez@progress.com>

* pipeline fix

Signed-off-by: Abdul-Az <aazeez@progress.com>
@@ -97,7 +99,8 @@ func serve(cmd *cobra.Command, args []string) {
// get secrets client
secretsClient := secrets.NewSecretsServiceClient(secretsConn)

service, err := service.Start(l, migrationConfig, connFactory, secretsClient, authzClient)
service, err := service.Start(l, migrationConfig, connFactory, secretsClient, authzClient, authzClientProject)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authzProjectClient can be a better name of the variable?

Suggested change
service, err := service.Start(l, migrationConfig, connFactory, secretsClient, authzClient, authzClientProject)
service, err := service.Start(l, migrationConfig, connFactory, secretsClient, authzClient, authzProjectClient)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to the suggested name

@@ -240,7 +241,11 @@ func (s *Server) GetInfraServerOrgs(ctx context.Context, req *request.GetInfraSe
// Save organisations in backend DB
orgs := []storage.Org{}
for key := range orgsList {
org, err := s.service.Storage.StoreOrg(ctx, key, key, "", "", req.ServerId, nil)
projects, err := createProjectFromOrgIdAndServerID(s, ctx, req.ServerId, key)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it create the policies too for the project?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we are passing skip policies as false, therefore its creating project with all the policies.

Yashvi Jain added 3 commits January 11, 2022 16:09
Signed-off-by: Yashvi Jain <Yashvi.jain@progress.com>
Signed-off-by: Yashvi Jain <Yashvi.jain@progress.com>
Signed-off-by: Yashvi Jain <Yashvi.jain@progress.com>
Yashvi Jain added 3 commits January 11, 2022 16:14
Signed-off-by: Yashvi Jain <Yashvi.jain@progress.com>
Signed-off-by: Yashvi Jain <Yashvi.jain@progress.com>
@sonarcloud
Copy link

sonarcloud bot commented Jan 11, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
21.2% 21.2% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automate-infra-proxy-api using for automate infra proxy backend api's infra-user-mgnt Team: Stalwart Migrate Chef Manage, UI bugs, UX improvements, CVE Issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants