Skip to content

Commit

Permalink
Programming exercises: Fix ssh local storage issue (#8317)
Browse files Browse the repository at this point in the history
  • Loading branch information
milljoniaer authored and Stephan Krusche committed Apr 5, 2024
1 parent 6629025 commit 817d554
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export class CloneRepoButtonComponent implements OnInit, OnChanges {
exercise?: Exercise;

useSsh = false;
sshKeysUrl: string;
sshEnabled: boolean;
sshTemplateUrl: string;
repositoryPassword: string;
sshKeysUrl?: string;
sshEnabled = false;
sshTemplateUrl?: string;
repositoryPassword?: string;
versionControlUrl: string;
versionControlAccessTokenRequired?: boolean;
localVCEnabled = false;
Expand Down Expand Up @@ -104,7 +104,7 @@ export class CloneRepoButtonComponent implements OnInit, OnChanges {
}

getHttpOrSshRepositoryUri(insertPlaceholder = true): string {
if (this.useSsh) {
if (this.useSsh && this.sshEnabled && this.sshTemplateUrl) {
return this.getSshCloneUrl(this.getRepositoryUri()) || this.getRepositoryUri();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ describe('CloneRepoButtonComponent', () => {
component.ngOnChanges();

component.useSsh = true;
component.sshEnabled = true;

expect(component.getHttpOrSshRepositoryUri()).toBe('ssh://[email protected]:7999/ITCPLEASE1/itcplease1-exercise.git');

Expand All @@ -150,6 +151,19 @@ describe('CloneRepoButtonComponent', () => {
expect(component.getHttpOrSshRepositoryUri()).toBe('ssh://[email protected]:7999/ITCPLEASE1/itcplease1-exercise.git');
});

it('should not use ssh when ssh is not enabled (even if useSsh is set)', () => {
participation.repositoryUri = `https://bitbucket.ase.in.tum.de/scm/ITCPLEASE1/itcplease1-exercise-team1.git`;
component.participations = [participation];
component.useSsh = true;
component.isTeamParticipation = false;
component.versionControlAccessTokenRequired = true;
component.ngOnInit();
component.ngOnChanges();

const url = component.getHttpOrSshRepositoryUri();
expect(url).toBe(`https://${component.user.login}:**********@bitbucket.ase.in.tum.de/scm/ITCPLEASE1/itcplease1-exercise-team1.git`);
});

it('should get html url (not the same url for team and individual participation)', () => {
participation.repositoryUri = info.versionControlUrl!;
participation.team = {};
Expand Down

0 comments on commit 817d554

Please sign in to comment.