-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console): create portal configuration service
(cherry picked from commit 6217a15) # Conflicts: # gravitee-apim-console-webui/src/entities/portal/portalSettings.ts
1 parent
6a742d0
commit 3b6fcd6
Showing
5 changed files
with
125 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
gravitee-apim-console-webui/src/services-ngx/portal-configuration.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { HttpTestingController } from '@angular/common/http/testing'; | ||
|
||
import { PortalConfigurationService } from './portal-configuration.service'; | ||
|
||
import { fakePortalConfiguration } from '../entities/portal/portalSettings.fixture'; | ||
import { CONSTANTS_TESTING, GioHttpTestingModule } from '../shared/testing'; | ||
|
||
describe('PortalConfigurationService', () => { | ||
let service: PortalConfigurationService; | ||
let httpTestingController: HttpTestingController; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [GioHttpTestingModule], | ||
}); | ||
|
||
httpTestingController = TestBed.inject(HttpTestingController); | ||
service = TestBed.inject(PortalConfigurationService); | ||
}); | ||
|
||
describe('getEnvConfiguration', () => { | ||
it('should call the API', (done) => { | ||
const portalConfigurationToGet = fakePortalConfiguration(); | ||
|
||
service.get().subscribe((portalSettings) => { | ||
expect(portalSettings).toMatchObject(portalConfigurationToGet); | ||
done(); | ||
}); | ||
|
||
httpTestingController.expectOne({ method: 'GET', url: `${CONSTANTS_TESTING.env.baseURL}/portal` }).flush(portalConfigurationToGet); | ||
}); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
gravitee-apim-console-webui/src/services-ngx/portal-configuration.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { Inject, Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { Constants } from '../entities/Constants'; | ||
import { PortalConfiguration } from '../entities/portal/portalSettings'; | ||
|
||
/** | ||
* Portal Configuration Service is to be used to read Portal settings regardless of user permissions | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class PortalConfigurationService { | ||
constructor( | ||
private readonly http: HttpClient, | ||
@Inject('Constants') private readonly constants: Constants, | ||
) {} | ||
|
||
get(): Observable<PortalConfiguration> { | ||
return this.http.get<PortalConfiguration>(`${this.constants.env.baseURL}/portal`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters