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

mendersoftware / gui / 951400782

pending completion
951400782

Pull #3900

gitlab-ci

web-flow
chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.16.5 to 5.17.0.
- [Release notes](https://github.com/testing-library/jest-dom/releases)
- [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/jest-dom/compare/v5.16.5...v5.17.0)

---
updated-dependencies:
- dependency-name: "@testing-library/jest-dom"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3900: chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

4446 of 6414 branches covered (69.32%)

8342 of 10084 relevant lines covered (82.73%)

186.0 hits per line

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

85.96
/src/js/components/settings/organization/samlconfig.js
1
// Copyright 2022 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React, { useEffect, useState } from 'react';
15
import Dropzone from 'react-dropzone';
16

17
// material ui
18
import { CloudUpload } from '@mui/icons-material';
19
import { Button } from '@mui/material';
20
import { listItemTextClasses } from '@mui/material/ListItemText';
21
import { makeStyles } from 'tss-react/mui';
22

23
import { useradmApiUrl } from '../../../constants/userConstants';
24
import { toggle } from '../../../helpers';
25
import ExpandableAttribute from '../../common/expandable-attribute';
26
import InfoHint from '../../common/info-hint';
27
import { maxWidth } from './organizationsettingsitem';
28
import SSOEditor from './ssoeditor';
29

30
const useStyles = makeStyles()(theme => ({
7✔
31
  configDetail: {
32
    maxWidth,
33
    [`.${listItemTextClasses.primary}`]: {
34
      color: theme.palette.text.disabled,
35
      fontSize: 'smaller'
36
    }
37
  },
38
  uploadIcon: {
39
    marginBottom: theme.spacing(-0.5),
40
    marginRight: theme.spacing()
41
  },
42
  tinyMargin: {
43
    marginLeft: theme.spacing(0.5),
44
    marginRight: theme.spacing(0.5)
45
  },
46
  wrapper: {
47
    alignItems: 'start',
48
    columnGap: theme.spacing(2),
49
    display: 'grid',
50
    gridTemplateColumns: `minmax(max-content, ${maxWidth}px) max-content max-content`,
51
    ['&.has-sso']: {
52
      gridTemplateColumns: `${maxWidth - 45}px 1fr`
53
    }
54
  }
55
}));
56

57
const defaultDetails = [
7✔
58
  { key: 'entityID', label: 'Entity ID', getValue: id => `${window.location.origin}${useradmApiUrl}/sso/sp/metadata/${id}` },
3✔
59
  { key: 'acs', label: 'ACS URL', getValue: id => `${window.location.origin}${useradmApiUrl}/auth/sso/${id}/acs` },
3✔
60
  { key: 'startURL', label: 'Start URL', getValue: id => `${window.location.origin}${useradmApiUrl}/auth/sso/${id}/login` }
3✔
61
];
62

63
export const SAMLConfig = ({ configs, onCancel, onSave, setSnackbar }) => {
7✔
64
  const [configDetails, setConfigDetails] = useState([]);
19✔
65
  const [fileContent, setFileContent] = useState('');
19✔
66
  const [hasSSOConfig, setHasSSOConfig] = useState(false);
19✔
67
  const [isEditing, setIsEditing] = useState(false);
19✔
68

69
  const config = configs.length ? configs[0] : undefined;
19✔
70
  const { id, ...content } = config || {};
19✔
71
  const configContent = content.config || '';
19✔
72

73
  const { classes } = useStyles();
19✔
74

75
  useEffect(() => {
19✔
76
    setHasSSOConfig(!!config);
7✔
77
    setFileContent(configContent);
7✔
78
    if (config?.config) {
7✔
79
      setConfigDetails(defaultDetails.map(item => ({ ...item, value: item.getValue(config.id) })));
9✔
80
    }
81
  }, [config, configContent]);
82

83
  const onCancelSSOSettings = () => {
19✔
84
    setHasSSOConfig(!!config);
×
85
    setFileContent(configContent);
×
86
    setIsEditing(false);
×
87
    onCancel();
×
88
  };
89

90
  const onSaveSSOSettings = () => {
19✔
91
    onSave(id, fileContent);
×
92
    setIsEditing(false);
×
93
  };
94

95
  const onDrop = acceptedFiles => {
19✔
96
    let reader = new FileReader();
1✔
97
    reader.fileName = acceptedFiles[0].name;
1✔
98
    reader.onerror = error => console.log('Error: ', error);
1✔
99
    reader.onload = () => {
1✔
100
      setIsEditing(true);
×
101
      setFileContent(reader.result);
×
102
    };
103
    reader.readAsBinaryString(acceptedFiles[0]);
1✔
104
  };
105

106
  const onOpenEditorClick = () => setIsEditing(toggle);
19✔
107

108
  return (
19✔
109
    <>
110
      <div className={`flexbox center-aligned ${classes.wrapper} ${hasSSOConfig ? 'has-sso' : ''}`}>
19✔
111
        {hasSSOConfig ? (
19✔
112
          <a onClick={onOpenEditorClick}>View metadata in the text editor</a>
113
        ) : (
114
          <>
115
            <Dropzone multiple={false} onDrop={onDrop}>
116
              {({ getRootProps, getInputProps }) => (
117
                <div {...getRootProps()} className="dropzone onboard dashboard-placeholder flexbox centered">
13✔
118
                  <input {...getInputProps()} />
119
                  <CloudUpload className={classes.uploadIcon} fontSize="small" /> Drag here or <a className={classes.tinyMargin}>browse</a> to upload a metadata
120
                  document
121
                </div>
122
              )}
123
            </Dropzone>
124
            <div>
125
              or <a onClick={onOpenEditorClick}>input with the text editor</a>
126
            </div>
127
          </>
128
        )}
129
        <div className="flexbox">
130
          {hasSSOConfig && !isEditing ? (
49✔
131
            <Button onClick={onOpenEditorClick}>Edit</Button>
132
          ) : (
133
            <>
134
              <Button onClick={onCancelSSOSettings}>Cancel</Button>
135
              <Button className={classes.tinyMargin} onClick={onSaveSSOSettings} disabled={!fileContent} variant="contained">
136
                Save
137
              </Button>
138
            </>
139
          )}
140
        </div>
141
      </div>
142
      {hasSSOConfig ? (
19✔
143
        <div className="flexbox column margin-top">
144
          {configDetails.map(item => (
145
            <ExpandableAttribute
33✔
146
              className={classes.configDetail}
147
              copyToClipboard
148
              key={item.key}
149
              primary={item.label}
150
              secondary={item.value}
151
              setSnackbar={setSnackbar}
152
              disableGutters
153
              dividerDisabled
154
            />
155
          ))}
156
        </div>
157
      ) : (
158
        <InfoHint content="Submit the metadata document from your Identity Provider" />
159
      )}
160
      <SSOEditor
161
        open={isEditing}
162
        config={configContent}
163
        fileContent={fileContent}
164
        hasSSOConfig={hasSSOConfig}
165
        onCancel={onCancelSSOSettings}
166
        onClose={onOpenEditorClick}
167
        onSave={onSaveSSOSettings}
168
        setFileContent={setFileContent}
169
      />
170
    </>
171
  );
172
};
173

174
export default SAMLConfig;
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