Use full baseUrl instead of baseUrl's origin
This commit is contained in:
committed by
Dat H. Pham
parent
e7566fcbe5
commit
b073cd9aa8
@@ -0,0 +1,80 @@
|
||||
import 'package:core/data/network/config/dynamic_url_interceptors.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('setJmapUrl test', () {
|
||||
test('should set jmapUrl to the full URI', () {
|
||||
final dynamicUrlInterceptors = DynamicUrlInterceptors();
|
||||
const fullUri = 'https://example.com/basicauth';
|
||||
|
||||
dynamicUrlInterceptors.setJmapUrl(fullUri);
|
||||
|
||||
expect(dynamicUrlInterceptors.jmapUrl, equals(fullUri));
|
||||
});
|
||||
|
||||
test('should set jmapUrl to the full URI when url have multiple sub-paths', () {
|
||||
final dynamicUrlInterceptors = DynamicUrlInterceptors();
|
||||
const fullUri = 'https://example.com/basicauth/jmap';
|
||||
|
||||
dynamicUrlInterceptors.setJmapUrl(fullUri);
|
||||
|
||||
expect(dynamicUrlInterceptors.jmapUrl, equals(fullUri));
|
||||
});
|
||||
|
||||
test('should set jmapUrl to the full URI when url have no sub-paths', () {
|
||||
final dynamicUrlInterceptors = DynamicUrlInterceptors();
|
||||
const fullUri = 'https://example.com';
|
||||
|
||||
dynamicUrlInterceptors.setJmapUrl(fullUri);
|
||||
|
||||
expect(dynamicUrlInterceptors.jmapUrl, equals(fullUri));
|
||||
});
|
||||
|
||||
test('should set jmapUrl to the full URI when url have port and sub-paths', () {
|
||||
final dynamicUrlInterceptors = DynamicUrlInterceptors();
|
||||
const fullUri = 'https://example.com:8080/basicauth/jmap/';
|
||||
|
||||
dynamicUrlInterceptors.setJmapUrl(fullUri);
|
||||
|
||||
expect(dynamicUrlInterceptors.jmapUrl, equals(fullUri));
|
||||
});
|
||||
});
|
||||
|
||||
group('changeBaseUrl test', () {
|
||||
test('should set baseUrl to the full URI', () {
|
||||
final dynamicUrlInterceptors = DynamicUrlInterceptors();
|
||||
const fullUri = 'https://example.com/basicauth';
|
||||
|
||||
dynamicUrlInterceptors.changeBaseUrl(fullUri);
|
||||
|
||||
expect(dynamicUrlInterceptors.baseUrl, equals(fullUri));
|
||||
});
|
||||
|
||||
test('should set baseUrl to the full URI when url have multiple sub-paths', () {
|
||||
final dynamicUrlInterceptors = DynamicUrlInterceptors();
|
||||
const fullUri = 'https://example.com/basicauth/jmap';
|
||||
|
||||
dynamicUrlInterceptors.changeBaseUrl(fullUri);
|
||||
|
||||
expect(dynamicUrlInterceptors.baseUrl, equals(fullUri));
|
||||
});
|
||||
|
||||
test('should set baseUrl to the full URI when url have no sub-paths', () {
|
||||
final dynamicUrlInterceptors = DynamicUrlInterceptors();
|
||||
const fullUri = 'https://example.com';
|
||||
|
||||
dynamicUrlInterceptors.changeBaseUrl(fullUri);
|
||||
|
||||
expect(dynamicUrlInterceptors.baseUrl, equals(fullUri));
|
||||
});
|
||||
|
||||
test('should set baseUrl to the full URI when url have port and sub-paths', () {
|
||||
final dynamicUrlInterceptors = DynamicUrlInterceptors();
|
||||
const fullUri = 'https://example.com:8080/basicauth/jmap/';
|
||||
|
||||
dynamicUrlInterceptors.changeBaseUrl(fullUri);
|
||||
|
||||
expect(dynamicUrlInterceptors.baseUrl, equals(fullUri));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -83,7 +83,7 @@ abstract class ReloadableController extends BaseController {
|
||||
|
||||
void _handleGetCredentialSuccess(GetCredentialViewState success) {
|
||||
_setDataToInterceptors(
|
||||
baseUrl: success.baseUrl.origin,
|
||||
baseUrl: success.baseUrl.toString(),
|
||||
userName: success.userName,
|
||||
password: success.password);
|
||||
getSessionAction();
|
||||
|
||||
Reference in New Issue
Block a user