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

Added teams functionality #380

Merged
merged 109 commits into from
Sep 3, 2020
Merged

Added teams functionality #380

merged 109 commits into from
Sep 3, 2020

Conversation

maximAtanasov
Copy link
Member

@maximAtanasov maximAtanasov commented Jun 16, 2020

Coderadar now provides functionality for adding and managing teams. Each team can be assigned to many projects and with different roles. Users now also have a role for any project that they have access to. Basic authentication and UI elements have also been added. Lots of works still needs to be done in the UI (and the Back-End will likely have to be adjusted), but this can be done later after we have discussed some of the details about the authentication concept and the UI elements.

maximAtanasov and others added 30 commits May 5, 2020 15:25
    AddTeamToProjectAdapter
    CreateTeamAdapter
    DeleteTeamAdapter
    ListProjectsForTeamAdapter
    ListTeamsForUserAdapter
    ListUsersAdapter
    TeamMapper
and applied spotless.
@maximAtanasov
Copy link
Member Author

Please apply the tslint fixes

Done

@maximAtanasov maximAtanasov requested a review from jo2 August 6, 2020 11:32

@BeforeEach
void setUp() {
coderadarConfigurationProperties.setAuthentication(
Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I know, til now, this is the only test using such a configuration. if there are more configurations like this, we should use a spring profile for tests to handle these configurations for us.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you mean by configuration. The credentials are basically mocked in these tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought this line would basically just set the property coderadar.authentication.enabled=true of he local.application.properties file. This was a misunderstanding by me.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is correct, however I did not undestand the issue.

testUser.setProjects(Collections.singletonList(testProject));
userRepository.save(testUser);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if there is no user with this id for this project? What happens if user and project do not exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you mean. The cases you describe are tested on lines 77 and 94.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The first means the user exists (has id 1) but he is not a user registered for this project. The test case you've used in line 77 is for a user which does not exist on our platform. For the second part, this file only does have 87 lines, at least in the GitHub view. What test is written in line 94?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, the lines I mentioned are for the SetUserRoleForProjectIntegrationTest. The first test checks if a user assigned to a project gets their role removed successfuly. The other two tests check that 404 is returned when a user/project does not exists. Is there something I'm missing?

testUser.setPassword(PasswordUtil.hash("password1"));
userRepository.save(testUser);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if there is no user with this id for this project? What happens if user and project do not exist?

import {ContributorMergeDialogComponent} from './components/contributor-merge-dialog/contributor-merge-dialog.component';
import {DeleteProjectDialogComponent} from './components/delete-project-dialog/delete-project-dialog.component';
import {AddProjectToTeamDialogComponent} from './components/add-project-to-team-dialog/add-project-to-team-dialog.component';
import {ContributorDialogComponent} from "./components/contributor-card/contributor-dialog.component";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please execute TSLint. It should emphasize doulbe quotes in ts files and more. TSLint issues should be fixed.

Copy link
Member Author

@maximAtanasov maximAtanasov Aug 7, 2020

Choose a reason for hiding this comment

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

Ts lint returns no errors for me. In fact running tslint --fix will remove all double quotes as those are counted as errors.

EDIT: I see the double quote now, I don't know why it was left out as I ran the linter last time. I'll fix it again.
EDIT2: Should we maybe make the linting a part of the build like it is for spotless?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've run the linter again

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, I think it would be a good idea to make it part of the build process!

@@ -214,7 +203,7 @@ export class ProjectService {
* @param branch The branch to use for getting the commits.
*/
public getCommitsForContributor(id: number, branch: string, email: string): Promise<HttpResponse<Commit[]>> {
return this.httpClient.get<Commit[]>(this.apiURL + 'projects/' + id + '/' + branch + '/commits?email='+email,
return this.httpClient.get<Commit[]>(this.apiURL + 'projects/' + id + '/' + branch + '/commits?email=' + email.replace('+', '%2B'),
Copy link
Collaborator

@jo2 jo2 Aug 7, 2020

Choose a reason for hiding this comment

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

Why do you replace all '+' in generated url with '%2B'? '+' has to be encoded, but I don't see any place where a '+' could be added to the url.

Also, if the urls have multiple parameter, we may consider using string literals to increase readability. That would be the scope of a new issue though.

Copy link
Member Author

Choose a reason for hiding this comment

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

The + sign is an edge case here. Some emails (those generate by GitHub for example) contain a plus sign. I agree about the string literals.

Copy link
Collaborator

@jo2 jo2 left a comment

Choose a reason for hiding this comment

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

Some things are stil left to do but it is coming to an end.

@maximAtanasov
Copy link
Member Author

@jo2 Do you want any more changes to be made in this PR?
I have worked on further fixes and improvements in another branch so as to not bloat this PR any more.

@jo2
Copy link
Collaborator

jo2 commented Sep 2, 2020

What I'm stil missing for the RemoveUserFromProjectControllerIntegrationTest is this case: user and projects both exist but the projects of the user do not contain the project. In that case userRepository.removeUserRoleFromProject is called and it tries to remove a non-existing relationship. Can this cause issues? In my opinion it should be tested. Otherwise this is ready for merge.

… to remove the role and write a test for this case
@maximAtanasov
Copy link
Member Author

Yes, you were correct in that this case wasn't handled. I've added a check for it and wrote a test.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 2, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 1 Code Smell

82.8% 82.8% Coverage
0.0% 0.0% Duplication

@maximAtanasov maximAtanasov merged commit 6baf7c6 into master Sep 3, 2020
@maximAtanasov maximAtanasov deleted the teams branch September 3, 2020 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants