• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

damienbod / angular-auth-oidc-client / 8331908843

18 Mar 2024 06:36PM UTC coverage: 92.928% (-4.1%) from 97.057%
8331908843

Pull #1848

github

web-flow
Merge d1b3fc040 into 6c778a4a2
Pull Request #1848: moving to strict mode

700 of 818 branches covered (85.57%)

Branch coverage included in aggregate %.

228 of 293 new or added lines in 48 files covered. (77.82%)

11 existing lines in 6 files now uncovered.

2559 of 2689 relevant lines covered (95.17%)

8.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.36
/projects/angular-auth-oidc-client/src/lib/storage/browser-storage.service.ts
1
import { Injectable } from '@angular/core';
2
import { OpenIdConfiguration } from '../config/openid-configuration';
3
import { LoggerService } from '../logging/logger.service';
4
import { AbstractSecurityStorage } from './abstract-security-storage';
5

6
@Injectable({ providedIn: 'root' })
7
export class BrowserStorageService {
1✔
8
  constructor(
9
    private readonly loggerService: LoggerService,
12✔
10
    private readonly abstractSecurityStorage: AbstractSecurityStorage
12✔
11
  ) {}
12

13
  read(key: string, configuration: OpenIdConfiguration): any {
14
    const { configId } = configuration;
3✔
15

16
    if (!configId) {
3!
NEW
17
      this.loggerService.logDebug(
×
18
        configuration,
19
        `Wanted to read '${key}' but configId was '${configId}'`
20
      );
21

NEW
22
      return null;
×
23
    }
24

25
    if (!this.hasStorage()) {
3✔
26
      this.loggerService.logDebug(
1✔
27
        configuration,
28
        `Wanted to read '${key}' but Storage was undefined`
29
      );
30

31
      return null;
1✔
32
    }
33

34
    const storedConfig = this.abstractSecurityStorage.read(configId);
2✔
35

36
    if (!storedConfig) {
2✔
37
      return null;
1✔
38
    }
39

40
    return JSON.parse(storedConfig);
1✔
41
  }
42

43
  write(value: any, configuration: OpenIdConfiguration): boolean {
44
    const { configId } = configuration;
3✔
45

46
    if (!configId) {
3!
NEW
47
      this.loggerService.logDebug(
×
48
        configuration,
49
        `Wanted to write but configId was '${configId}'`
50
      );
51

NEW
52
      return false;
×
53
    }
54

55
    if (!this.hasStorage()) {
3✔
56
      this.loggerService.logDebug(
1✔
57
        configuration,
58
        `Wanted to write but Storage was falsy`
59
      );
60

61
      return false;
1✔
62
    }
63

64
    value = value || null;
2✔
65

66
    this.abstractSecurityStorage.write(configId, JSON.stringify(value));
2✔
67

68
    return true;
2✔
69
  }
70

71
  remove(key: string, configuration: OpenIdConfiguration): boolean {
72
    if (!this.hasStorage()) {
2✔
73
      this.loggerService.logDebug(
1✔
74
        configuration,
75
        `Wanted to remove '${key}' but Storage was falsy`
76
      );
77

78
      return false;
1✔
79
    }
80

81
    // const storage = this.getStorage(configuration);
82
    // if (!storage) {
83
    //   this.loggerService.logDebug(configuration, `Wanted to write '${key}' but Storage was falsy`);
84

85
    //   return false;
86
    // }
87

88
    this.abstractSecurityStorage.remove(key);
1✔
89

90
    return true;
1✔
91
  }
92

93
  // TODO THIS STORAGE WANTS AN ID BUT CLEARS EVERYTHING
94
  clear(configuration: OpenIdConfiguration): boolean {
95
    if (!this.hasStorage()) {
2✔
96
      this.loggerService.logDebug(
1✔
97
        configuration,
98
        `Wanted to clear storage but Storage was falsy`
99
      );
100

101
      return false;
1✔
102
    }
103

104
    // const storage = this.getStorage(configuration);
105
    // if (!storage) {
106
    //   this.loggerService.logDebug(configuration, `Wanted to clear storage but Storage was falsy`);
107

108
    //   return false;
109
    // }
110

111
    this.abstractSecurityStorage.clear();
1✔
112

113
    return true;
1✔
114
  }
115

116
  private hasStorage(): boolean {
117
    return typeof Storage !== 'undefined';
1✔
118
  }
119
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc